﻿namespace Fiddler
{
    using Microsoft.Win32;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Globalization;
    using System.IO;
    using System.Net;
    using System.Reflection;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading;
    using System.Windows.Forms;
    using Xceed.FileSystem;
    using Xceed.Zip;

    public class frmViewer : Form
    {
        private Form _frmFloatingInspectors;
        private int _iUnsquishedSessionListWidth;
        private Point _ptContextPopup;
        private HiddenMessagingWindow _wndForMessages;
        private Button btnDecodeRequest;
        private Button btnDecodeResponse;
        private Button btnPromptHTTPS;
        private Button btnSquish;
        private Button btnTamperSendClient;
        private Button btnTamperSendServer;
        private Button btnWarnDetached;
        private ComboBox cbxLoadFrom;
        private ColumnHeader colComments;
        private ColumnHeader colContentType;
        private ColumnHeader colCustom;
        private ColumnHeader colExpires;
        private ColumnHeader colHost;
        private ColumnHeader colID;
        private ColumnHeader colProcess;
        private ColumnHeader colProtocol;
        private ColumnHeader colRequest;
        private ColumnHeader colResponseSize;
        private ColumnHeader colStatus;
        private IContainer components;
        private OpenFileDialog dlgLoadZip;
        private SaveFileDialog dlgSaveBinary;
        private SaveFileDialog dlgSaveZip;
        public ImageList imglSessionIcons;
        public ImageList imglToolbar;
        private Label lblBreakpoint;
        private Label lblInspectOne;
        private Label lblSessions;
        public SessionListView lvSessions;
        private MenuItem menuItem1;
        private MenuItem menuItem16;
        private MenuItem menuItem18;
        private MenuItem menuItem19;
        private MenuItem menuItem20;
        private MenuItem menuItem21;
        private MenuItem menuItem26;
        private MenuItem menuItem28;
        private MenuItem menuItem32;
        private MenuItem menuItem7;
        public MenuItem miCaptureEnabled;
        private MenuItem miCaptureRules;
        private MenuItem miCaptureSplit;
        private MenuItem miContextMarkSplit;
        private MenuItem miContextSaveAndOpenBody;
        private MenuItem miContextSaveSplitter;
        private MenuItem miEditCopyFullSummary;
        private MenuItem miEditCopyHeaders;
        private MenuItem miEditCopySession;
        private MenuItem miEditCopyTerseSummary;
        private MenuItem miEditCopyUrl;
        private MenuItem miEditDivider;
        private MenuItem miEditFind;
        private MenuItem miEditMarkBlue;
        private MenuItem miEditMarkGold;
        private MenuItem miEditMarkGreen;
        private MenuItem miEditMarkOrange;
        private MenuItem miEditMarkPurple;
        private MenuItem miEditMarkRed;
        private MenuItem miEditMarkUnmark;
        private MenuItem miEditPaste;
        private MenuItem miEditRemoveAll;
        private MenuItem miEditRemoveSelected;
        private MenuItem miEditRemoveUnselected;
        private MenuItem miEditSelectAll;
        private MenuItem miEditSplit1;
        private MenuItem miEditUnlock;
        private MenuItem miFileExit;
        private MenuItem miFileLoad;
        private MenuItem miFileMRUClear;
        private MenuItem miFileMRUPrune;
        private MenuItem miFileMRUSplit;
        private MenuItem miFileNew;
        private MenuItem miFileSaveAllSessions;
        private MenuItem miFileSaveAndOpenBody;
        private MenuItem miFileSaveHeaders;
        private MenuItem miFileSaveRequest;
        private MenuItem miFileSaveRequestBody;
        private MenuItem miFileSaveResponse;
        private MenuItem miFileSaveResponseBody;
        private MenuItem miFileSaveSession;
        private MenuItem miFileSaveZip;
        private MenuItem miHelpAbout;
        private MenuItem miHelpCommunity;
        private MenuItem miHelpContents;
        private MenuItem miHelpHTTP;
        private MenuItem miHelpReportBug;
        private MenuItem miHelpShowFiltered;
        private MenuItem miHelpSplit1;
        private MenuItem miHelpSplit2;
        private MenuItem miHelpSplit3;
        private MenuItem miHelpUpdates;
        private MenuItem miInspectorHide;
        private MenuItem miInspectorProperties;
        public MenuItem miManipulateGZIP;
        public MenuItem miManipulateIgnoreImages;
        public MenuItem miManipulateRequireProxyAuth;
        public ToolStripMenuItem miNotifyCapturing;
        private ToolStripMenuItem miNotifyExit;
        private ToolStripMenuItem miNotifyRestore;
        private MenuItem miReissueSplit;
        private MenuItem miRulesBreakAt;
        private MenuItem miRulesBreakAtNothing;
        public MenuItem miRulesBreakAtRequest;
        public MenuItem miRulesBreakAtResponse;
        private MenuItem miRulesBreakpointsIgnoreImages;
        public MenuItem miRulesIgnoreConnects;
        public MenuItem miRulesRemoveEncoding;
        private MenuItem miRulesSplit1;
        private MenuItem miSessionAbort;
        private MenuItem miSessionAddComment;
        private MenuItem miSessionCOMETPeek;
        private MenuItem miSessionContextSplit;
        public MenuItem miSessionCopy;
        private MenuItem miSessionCopyColumn;
        private MenuItem miSessionCopyEntire;
        private MenuItem miSessionCopyHeaders;
        private MenuItem miSessionCopyHeadlines;
        private MenuItem miSessionCopyResponseAsDataURI;
        private MenuItem miSessionCopySummary;
        private MenuItem miSessionCopyURL;
        private MenuItem miSessionFilter;
        private MenuItem miSessionInspectNewWindow;
        internal MenuItem miSessionListScroll;
        private MenuItem miSessionMark;
        private MenuItem miSessionMarkBlue;
        private MenuItem miSessionMarkGold;
        private MenuItem miSessionMarkGreen;
        private MenuItem miSessionMarkOrange;
        private MenuItem miSessionMarkPurple;
        private MenuItem miSessionMarkRed;
        private MenuItem miSessionMarkUnmark;
        public MenuItem miSessionProperties;
        private MenuItem miSessionReissueComposer;
        private MenuItem miSessionReissueEdited;
        private MenuItem miSessionReissueInIE;
        private MenuItem miSessionReissueRequests;
        private MenuItem miSessionReissueUnconditionally;
        private MenuItem miSessionRemove;
        private MenuItem miSessionRemoveAll;
        private MenuItem miSessionRemoveSelected;
        private MenuItem miSessionRemoveUnselected;
        public MenuItem miSessionReplay;
        private MenuItem miSessionReplayResponse;
        public MenuItem miSessionSave;
        private MenuItem miSessionSaveEntire;
        private MenuItem miSessionSaveFullRequest;
        private MenuItem miSessionSaveFullResponse;
        private MenuItem miSessionSaveHeaders;
        private MenuItem miSessionSaveRequestBody;
        private MenuItem miSessionSaveResponseBody;
        private MenuItem miSessionSaveToZip;
        public MenuItem miSessionSelect;
        private MenuItem miSessionSelectChildren;
        private MenuItem miSessionSelectDuplicates;
        private MenuItem miSessionSelectParent;
        private MenuItem miSessionSplit;
        private MenuItem miSessionSplit2;
        private MenuItem miSessionUnlock;
        private MenuItem miSessionWinDiff;
        private MenuItem miToolsClearCache;
        private MenuItem miToolsClearCookies;
        private MenuItem miToolsCompare;
        private MenuItem miToolsEncodeDecode;
        private MenuItem miToolsInternetOptions;
        private MenuItem miToolsOptions;
        private MenuItem miToolsSplit1;
        private MenuItem miToolsSplit2;
        private MenuItem miToolsSplitCustom;
        internal MenuItem miViewAutoScroll;
        private MenuItem miViewBuilder;
        private MenuItem miViewDefault;
        private MenuItem miViewInspector;
        private MenuItem miViewMinimizeToTray;
        private MenuItem miViewRefresh;
        private MenuItem miViewSplit1;
        private MenuItem miViewSplit2;
        private MenuItem miViewSplit3;
        private MenuItem miViewSquish;
        public MenuItem miViewStacked;
        private MenuItem miViewStatistics;
        private MenuItem miViewStayOnTop;
        private MenuItem miViewToolbar;
        private MenuItem miViewWide;
        private MenuItem mnuContextSaveRequest;
        private MenuItem mnuContextSaveResponse;
        private MenuItem mnuContextSaveSessions;
        private MenuItem mnuEdit;
        private MenuItem mnuEditCopy;
        private MenuItem mnuEditMark;
        private MenuItem mnuEditRemove;
        private MenuItem mnuFile;
        private MenuItem mnuFileExport;
        private MenuItem mnuFileMRU;
        private MenuItem mnuFileSave;
        private MenuItem mnuFileSaveRequest;
        private MenuItem mnuFileSaveResponse;
        private MenuItem mnuFileSaveSessions;
        private MenuItem mnuHelp;
        private ContextMenu mnuInspectorsContext;
        public MainMenu mnuMain;
        public ContextMenuStrip mnuNotify;
        public MenuItem mnuRules;
        public ContextMenu mnuSessionContext;
        public MenuItem mnuTools;
        private MenuItem mnuView;
        internal NotifyIcon notifyIcon;
        private static System.Windows.Forms.Timer oReportingQueueTimer = new System.Windows.Forms.Timer();
        private MRU oSAZMRU;
        public TabPage pageBuilder;
        public TabPage pageInspector;
        public TabPage pageResponder;
        public TabPage pageStatistics;
        private Panel pnlInfoBar;
        internal Panel pnlInfoTip;
        internal Panel pnlInfoTipRequest;
        private Panel pnlInspector;
        private Panel pnlSessionControls;
        public Panel pnlSessions;
        private Panel pnlTopNotice;
        private StatusBarPanel sbpBreakpoints;
        private StatusBarPanel sbpCapture;
        public StatusBarPanel sbpInfo;
        private StatusBarPanel sbpProcessFilter;
        private StatusBarPanel sbpSelCount;
        public StatusBar sbStatus;
        private Splitter splitterInspector;
        private Splitter splitterMain;
        internal TabControl tabsRequest;
        private TabControl tabsResponse;
        public TabControl tabsViews;
        private ToolStripSeparator toolStripMenuItem1;
        private QuickExec txtExec;

        public event EventHandler<QuickExecEventArgs> OnQuickExec;
           private delegate void  UpdateUIDelegate();

        public frmViewer()
        {
            this.InitializeComponent();
        }

        private void _addScreenshotNow()
        {
            HTTPRequestHeaders headers = new HTTPRequestHeaders();
            headers.HTTPMethod = "GET";
            headers.Add("Host", "localhost");
            headers.RequestPath = "/Screenshot_" + DateTime.Now.ToString("H-mm-ss") + ".jpg";
            byte[] arrRequest = headers.ToByteArray(true, true, false);
            byte[] bytes = Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nConnection: close\r\n\r\n");
            MemoryStream stream = new MemoryStream();
            stream.Write(bytes, 0, bytes.Length);
            Screen screen = Screen.FromPoint(Cursor.Position);
            Bitmap image = new Bitmap(screen.Bounds.Width, screen.Bounds.Height, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(image);
            graphics.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, screen.Bounds.Size, CopyPixelOperation.SourceCopy);
            graphics.Dispose();
            image.Save(stream, ImageFormat.Jpeg);
            Session oSession = new Session(arrRequest, stream.ToArray(), SessionFlags.ServedFromCache | SessionFlags.ImportedFromOtherTool | SessionFlags.ResponseGeneratedByFiddler | SessionFlags.RequestGeneratedByFiddler);
            if (FiddlerApplication.UI.InvokeRequired)
            {
                FiddlerApplication.UIInvokeAsync(new updateUIDelegate(FiddlerApplication._frmMain.finishSession), new object[] { oSession });
            }
            else
            {
                this.finishSession(oSession);
            }
        }

        private void _coreAddSession(Session oSession, bool bInsideFinishSession)
        {
            ListViewItem oLVI = new ListViewItem(oSession.id.ToString(), 0);
            oLVI.Tag = oSession;
            oSession.ViewItem = oLVI;
            oLVI.SubItems.AddRange(new string[] { " - ", _obtainScheme(oSession), oSession.host, oSession.PathAndQuery, "-1", string.Empty, string.Empty, oSession["SESSION", "x-ProcessInfo"], oSession["SESSION", "ui-comments"], oSession["SESSION", "ui-customcolumn"] });
            oLVI.SubItems.AddRange(this.lvSessions._emptyBoundColumns);
            if (!bInsideFinishSession)
            {
                if (oSession.state == SessionStates.Aborted)
                {
                    oLVI.ImageIndex = 14;
                }
                SessionListView.FillBoundColumns(oSession, oLVI);
                if (oSession.HTTPMethodIs("CONNECT"))
                {
                    oLVI.SubItems[3].Text = "Tunnel to";
                    oLVI.ForeColor = System.Drawing.Color.Gray;
                }
            }
            this.lvSessions.QueueItem(oLVI);
            if (oSession.oFlags.ContainsKey("x-Builder-Inspect"))
            {
                this.lvSessions.FlushUpdates();
                this.lvSessions.SelectedItems.Clear();
                oSession.ViewItem.Selected = true;
                oSession.ViewItem.Focused = true;
                oSession.ViewItem.EnsureVisible();
                this.tabsViews.SelectedTab = this.pageInspector;
            }
        }

        private TabPage _GetTabPageFromPoint(Point pt)
        {
            for (int i = 0; i < this.tabsViews.TabPages.Count; i++)
            {
                if (this.tabsViews.GetTabRect(i).Contains(pt))
                {
                    return this.tabsViews.TabPages[i];
                }
            }
            return null;
        }

        private void _initBookMenu()
        {
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.menus.book.visible", true))
            {
                MenuItem mnuBook = new MenuItem("GET /book");
                mnuBook.MenuItems.Add("&Get the Fiddler book...").Click += delegate(object s, EventArgs obj)
                {
                    Utilities.LaunchHyperlink(CONFIG.GetUrl("REDIR") + "FiddlerBook");
                };
                mnuBook.MenuItems.Add("&Hide this menu").Click += delegate(object s, EventArgs obj)
                {
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.menus.book.visible", false);
                    this.mnuMain.MenuItems.Remove(mnuBook);
                };
                this.mnuMain.MenuItems.Add(mnuBook);
            }
        }

        private void _initImportExportMenu()
        {
            this.mnuFileExport = new MenuItem("&Export Sessions");
            this.mnuFile.MenuItems.Add(6, this.mnuFileExport);
            MenuItem miSub = new MenuItem("&All Sessions...");
            this.mnuFileExport.MenuItems.Add(miSub);
            miSub.Click += delegate(object s, EventArgs ea)
            {
                this.actDoExport(null);
            };
            miSub = new MenuItem("&Selected Sessions...");
            this.mnuFileExport.MenuItems.Add(miSub);
            miSub.Click += delegate(object s, EventArgs ea)
            {
                Session[] oSelectedSessions = FiddlerApplication.UI.GetSelectedSessions();
                if (oSelectedSessions.Length > 0)
                {
                    this.actDoExport(oSelectedSessions);
                }
            };
            this.mnuFileExport.Popup += delegate(object s, EventArgs ea)
            {
                miSub.Enabled = FiddlerApplication.UI.lvSessions.SelectedCount > 0;
            };
            MenuItem item = new MenuItem("&Import Sessions...");
            this.mnuFile.MenuItems.Add(6, item);
            item.Click += delegate(object s, EventArgs ea)
            {
                string[] array = FiddlerApplication.oTranscoders.getImportFormats();
                if (array.Length > 0)
                {
                    Array.Sort<string>(array);
                    string sImportFormat = actSelectImportExportFormat(true, array);
                    Session[] sessionArray = FiddlerApplication.DoImport(sImportFormat, true, null, null);
                    if (sessionArray != null)
                    {
                        this.sbpInfo.Text = string.Concat(new object[] { "Import from ", sImportFormat, " completed. Loaded ", sessionArray.Length, " sessions." });
                    }
                }
                else
                {
                    FiddlerApplication.DoNotifyUser(string.Format("You can install Importers from {0}FIDDLERTRANSCODERS", CONFIG.GetUrl("REDIR")), "No Importers Installed");
                }
            };
            MenuItem item2 = new MenuItem("-");
            this.mnuFile.MenuItems.Add(6, item2);
        }

        internal void _internalTrimSessionList(int iTrimTo, bool bFlushUpdates)
        {
            if (bFlushUpdates)
            {
                this.lvSessions.FlushUpdates();
            }
            this.lvSessions.BeginUpdate();
            Session[] allSessions = this.GetAllSessions();
            int num = allSessions.Length - iTrimTo;
            for (uint i = 0; (i < allSessions.Length) && (num > 0); i++)
            {
                if (((allSessions[i] != null) && (allSessions[i].ViewItem != null)) && (allSessions[i].state >= SessionStates.Done))
                {
                    num--;
                    if (((!(allSessions[i].oFlags["ui-bold"] == "user-marked") && string.IsNullOrEmpty(allSessions[i].oFlags["ui-comments"])) && ((allSessions[i].__ViewForm == null) && (allSessions[i].state != SessionStates.HandTamperRequest))) && (allSessions[i].state != SessionStates.HandTamperResponse))
                    {
                        allSessions[i].ViewItem.Remove();
                    }
                }
            }
            this.lvSessions.EndUpdate();
            this.UpdateStatusBar(true);
        }

        private void _LoadAnySAZSpecifiedViaCommandLine()
        {
            foreach (string str in Environment.GetCommandLineArgs())
            {
                if (str.EndsWith(".saz", StringComparison.OrdinalIgnoreCase))
                {
                    this.actLoadSessionArchive(str);
                    return;
                }
            }
        }

        private static void _LogExceptionToEventLog(Exception unhandledException)
        {
            try
            {
                if (!EventLog.SourceExists("Fiddler"))
                {
                    EventLog.CreateEventSource("Fiddler", "Fiddler Error Log");
                }
                EventLog log = new EventLog();
                log.Source = "Fiddler";
                log.WriteEntry(unhandledException.Message + "\n" + unhandledException.StackTrace);
            }
            catch (Exception)
            {
            }
        }

        private static string _obtainScheme(Session oSession)
        {
            if ((oSession.oRequest != null) && (oSession.oRequest.headers != null))
            {
                return oSession.oRequest.headers.UriScheme.ToUpper();
            }
            return "?";
        }

        private void _QuickExecHandlePrefs(string[] sParams)
        {
            if (sParams.Length < 2)
            {
                MessageBox.Show("set <name> <value>\r\nremove <name>\r\nshow {optional filter}\r\nlog\r\n", "Valid Actions");
            }
            else
            {
                switch (sParams[1].ToLower())
                {
                    case "log":
                        FiddlerApplication.Log.LogString(FiddlerApplication._Prefs.ToString(true));
                        this.sbpInfo.Text = "Dumped preferences to log";
                        return;

                    case "show":
                        if (sParams.Length == 2)
                        {
                            FiddlerApplication.DoNotifyUser(FiddlerApplication._Prefs.ToString(true), "All Preferences");
                            return;
                        }
                        FiddlerApplication.DoNotifyUser(FiddlerApplication._Prefs.FindMatches(sParams[2]), "Preferences matching '" + sParams[2] + "'");
                        return;

                    case "set":
                        if (sParams.Length != 4)
                        {
                            MessageBox.Show("Correct Syntax is:\r\n\r\n\tprefs SET prefName \"new value\"", "Invalid Parameters");
                            return;
                        }
                        FiddlerApplication.Prefs.SetStringPref(sParams[2], sParams[3]);
                        this.sbpInfo.Text = string.Format("Set preference '{0}' to '{1}'", sParams[2], sParams[3]);
                        return;

                    case "remove":
                        if (sParams.Length != 3)
                        {
                            MessageBox.Show("Correct Syntax is:\r\n\r\n\tprefs REMOVE prefName", "Invalid Parameters");
                            return;
                        }
                        FiddlerApplication.Prefs.RemovePref(sParams[2]);
                        this.sbpInfo.Text = string.Format("Removed preference '{0}'", sParams[2]);
                        return;
                }
                MessageBox.Show("set <name> <value>\r\nremove <name>\r\nshow {optional filter}\r\nlog\r\n", "Valid Actions");
            }
        }

        private void _RefreshSessionListViewItem(Session oSession, ListViewItem lvi)
        {
            int num = 4;
            try
            {
                SessionListView.FillBoundColumns(oSession, lvi);
                lvi.SubItems[2].Text = _obtainScheme(oSession);
                lvi.SubItems[1].Text = ((oSession.oResponse == null) || (oSession.oResponse.headers == null)) ? " - " : oSession.responseCode.ToString();
                lvi.SubItems[3].Text = oSession.host;
                lvi.SubItems[4].Text = oSession.PathAndQuery;
                lvi.SubItems[10].Text = oSession.oFlags["ui-customcolumn"];
                lvi.SubItems[9].Text = oSession.oFlags["ui-comments"];
                if (oSession.responseBodyBytes != null)
                {
                    lvi.SubItems[5].Text = string.Format("{0:N0}", oSession.responseBodyBytes.LongLength);
                }
                else
                {
                    lvi.SubItems[5].Text = (oSession.state <= SessionStates.ReadingResponse) ? "-1" : "0";
                }
                string sString = string.Empty;
                if ((oSession.oResponse != null) && (oSession.oResponse.headers != null))
                {
                    sString = oSession.oResponse.headers["Content-Type"];
                    lvi.SubItems[7].Text = sString;
                    sString = Utilities.TrimAfter(sString, ' ');
                    lvi.SubItems[6].Text = string.Empty;
                    if (oSession.oResponse.headers.Exists("Cache-Control"))
                    {
                        lvi.SubItems[6].Text = oSession.oResponse.headers["Cache-Control"] + "  ";
                    }
                    if (oSession.oResponse.headers.Exists("Expires"))
                    {
                        ListViewItem.ListViewSubItem item1 = lvi.SubItems[6];
                        item1.Text = item1.Text + "Expires: " + oSession.oResponse.headers["Expires"];
                    }
                }
                if (oSession.isTunnel)
                {
                    if (SessionStates.Aborted != oSession.state)
                    {
                        num = oSession.isFlagSet(SessionFlags.IsWebSocketTunnel) ? 0x22 : 13;
                    }
                    else
                    {
                        num = 14;
                    }
                    if (oSession.HTTPMethodIs("CONNECT"))
                    {
                        lvi.SubItems[3].Text = "Tunnel to";
                        lvi.ForeColor = System.Drawing.Color.Gray;
                    }
                    else
                    {
                        lvi.ForeColor = System.Drawing.Color.Olive;
                    }
                }
                else if (((oSession.responseCode == 0xcc) || oSession.HTTPMethodIs("HEAD")) || oSession.HTTPMethodIs("OPTIONS"))
                {
                    num = 0x10;
                }
                else if (((oSession.responseCode == 0x191) || (oSession.responseCode == 0x193)) || (oSession.responseCode == 0x197))
                {
                    num = 15;
                    lvi.ForeColor = System.Drawing.Color.Olive;
                }
                else if ((oSession.responseCode >= 400) || (oSession.responseCode < 100))
                {
                    num = 12;
                    lvi.ForeColor = System.Drawing.Color.Red;
                }
                else if (Utilities.IsRedirectStatus(oSession.responseCode))
                {
                    num = 10;
                }
                else if (oSession.responseCode == 0x130)
                {
                    lvi.ForeColor = System.Drawing.Color.Gray;
                    num = 11;
                }
                else if (oSession.responseCode == 0xce)
                {
                    num = 0x25;
                }
                else if (sString.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
                {
                    lvi.ForeColor = System.Drawing.Color.Gray;
                    num = 5;
                }
                else if ((sString.StartsWith("application/x-javascript", StringComparison.OrdinalIgnoreCase) || sString.StartsWith("application/javascript", StringComparison.OrdinalIgnoreCase)) || sString.StartsWith("text/javascript", StringComparison.OrdinalIgnoreCase))
                {
                    lvi.ForeColor = System.Drawing.Color.ForestGreen;
                    num = 6;
                }
                else if (sString.StartsWith("text/css", StringComparison.OrdinalIgnoreCase))
                {
                    lvi.ForeColor = System.Drawing.Color.Purple;
                    num = 9;
                }
                else if (sString.StartsWith("text/htm", StringComparison.OrdinalIgnoreCase))
                {
                    lvi.ForeColor = System.Drawing.Color.Blue;
                    num = 8;
                }
                else if (sString.StartsWith("application/x-shockwave-flash", StringComparison.OrdinalIgnoreCase))
                {
                    num = 30;
                }
                else if ((sString.StartsWith("text/xml", StringComparison.OrdinalIgnoreCase) || sString.StartsWith("application/xml", StringComparison.OrdinalIgnoreCase)) || sString.EndsWith("+xml", StringComparison.OrdinalIgnoreCase))
                {
                    num = 7;
                }
                else if (sString.StartsWith("application/x-silverlight-app", StringComparison.OrdinalIgnoreCase))
                {
                    num = 0x1f;
                }
                else if (sString.StartsWith("audio/", StringComparison.OrdinalIgnoreCase))
                {
                    num = 0x1c;
                }
                else if (sString.StartsWith("video/", StringComparison.OrdinalIgnoreCase))
                {
                    num = 0x1b;
                }
                else if ((sString.StartsWith("font/", StringComparison.OrdinalIgnoreCase) || sString.StartsWith("application/vnd.ms-fontobject", StringComparison.OrdinalIgnoreCase)) || sString.StartsWith("application/x-woff", StringComparison.OrdinalIgnoreCase))
                {
                    num = 0x1d;
                }
                else if (sString.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                {
                    num = 0x21;
                }
                switch (num)
                {
                    case 0x10:
                    case 15:
                    case 12:
                        break;

                    default:
                        if (oSession.isFlagSet(SessionFlags.IsWebSocketTunnel))
                        {
                            num = 0x22;
                        }
                        if (oSession.HTTPMethodIs("POST"))
                        {
                            num = 0x20;
                        }
                        break;
                }
                string sColor = oSession.oFlags["ui-color"];
                if (sColor != null)
                {
                    lvi.ForeColor = Utilities.GetColorFromString(sColor);
                }
                sColor = oSession.oFlags["ui-backcolor"];
                if (sColor != null)
                {
                    lvi.BackColor = Utilities.GetColorFromString(sColor);
                }
                else if (oSession.isAnyFlagSet(SessionFlags.ImportedFromOtherTool | SessionFlags.LoadedFromSAZ))
                {
                    lvi.BackColor = System.Drawing.Color.WhiteSmoke;
                }
                if (oSession.oFlags.ContainsKey("ui-bold"))
                {
                    lvi.Font = new Font(lvi.Font, lvi.Font.Style | FontStyle.Bold);
                }
                if (oSession.oFlags.ContainsKey("ui-italic"))
                {
                    lvi.Font = new Font(lvi.Font, lvi.Font.Style | FontStyle.Italic);
                }
                if (oSession.oFlags.ContainsKey("ui-strikeout"))
                {
                    lvi.Font = new Font(lvi.Font, lvi.Font.Style | FontStyle.Strikeout);
                }
                if ((oSession.state == SessionStates.Aborted) && (oSession.oFlags.ContainsKey("X-Fiddler-Aborted") || !oSession.isAnyFlagSet(SessionFlags.RequestGeneratedByFiddler)))
                {
                    num = 14;
                }
                if (oSession.state >= SessionStates.Done)
                {
                    lvi.ImageIndex = num;
                }
            }
            catch (Exception)
            {
            }
        }

        internal void _SetProcessFilter(ProcessFilterCategories oCat)
        {
            CONFIG.iShowProcessFilter = oCat;
            this.uihlpUpdateProcessFilterStatus();
        }

        private void _UpdateBreakpointMenu()
        {
            if (this.miRulesBreakAtRequest.Checked)
            {
                this.sbpBreakpoints.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[1]);
                this.sbpBreakpoints.Style = StatusBarPanelStyle.Text;
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonrequest", true);
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonresponse", false);
            }
            else if (this.miRulesBreakAtResponse.Checked)
            {
                this.sbpBreakpoints.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[3]);
                this.sbpBreakpoints.Style = StatusBarPanelStyle.Text;
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonrequest", false);
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonresponse", true);
            }
            else
            {
                this.sbpBreakpoints.Style = StatusBarPanelStyle.OwnerDraw;
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonrequest", false);
                FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.breakonresponse", false);
            }
        }

        private void _UpdateStatusBar()
        {
            int selectedCount = this.lvSessions.SelectedCount;
            if (selectedCount < 1)
            {
                this.sbpSelCount.Text = string.Format("{0:N0}", this.lvSessions.Items.Count);
            }
            else
            {
                this.sbpSelCount.Text = string.Format("{0:N0} / {1:N0}", selectedCount, this.lvSessions.Items.Count);
            }
        }

        private void _VerifyFiddlerIsFresh()
        {
            if ((!CONFIG.QuietMode && !CONFIG.bVersionCheckBlocked) && (!CONFIG.bVersionCheck && FiddlerApplication.Prefs.GetBoolPref("fiddler.updater.CheckFreshness", true)))
            {
                try
                {
                    FiddlerBuildDate date = (FiddlerBuildDate)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(FiddlerBuildDate), false)[0];
                    if (date.IsOutdated && (DialogResult.Yes == MessageBox.Show("Sorry to bother you, but this version of Fiddler is now quite outdated.\n\nCan we check for a new version real quick?", "What's that smell?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)))
                    {
                        actCheckForUpdates(true);
                    }
                }
                catch (Exception)
                {
                }
            }
        }

        [CodeDescription("Attach Fiddler as the WinINET proxy.")]
        public void actAttachProxy()
        {
            this.actAttachProxy(true);
        }

        internal void actAttachProxy(bool bNeedGWInfo)
        {
            this.pnlTopNotice.Visible = false;
            if (FiddlerApplication.oProxy.Attach(bNeedGWInfo))
            {
                this.sbpCapture.Text = "Capturing";
                this.sbpCapture.Style = StatusBarPanelStyle.Text;
            }
        }

        public void actCaptureScreenshot(bool bDelay)
        {
            if (bDelay)
            {
                this.actCaptureScreenshot(FiddlerApplication.Prefs.GetInt32Pref("fiddler.screenshot.DelayMS", 0x1388));
            }
            else
            {
                this.actCaptureScreenshot(0);
            }
        }

        [CodeDescription("Add a screenshot to the capture, delaying the specified number of milliseconds.")]
        public void actCaptureScreenshot(int iDelayMS)
        {
            DoWorkEventHandler handler = null;
            try
            {
                if (iDelayMS > 0)
                {
                    BackgroundWorker worker = new BackgroundWorker();
                    if (handler == null)
                    {
                        handler = delegate(object s, DoWorkEventArgs ea)
                        {
                            if (iDelayMS > 0x3e8)
                            {
                                string str = FiddlerApplication.Prefs.GetStringPref("fiddler.sounds.Countdown", CONFIG.GetPath("App") + "Countdown.wav");
                                MethodInvoker oDel = null;
                                for (int iX = iDelayMS; iX > 0; iX -= 0x3e8)
                                {
                                    if (oDel == null)
                                    {
                                        oDel = () => FiddlerToolbar.SetScreenshotCounter(" ( " + ((iX / 0x3e8)).ToString() + "... )");
                                    }
                                    FiddlerApplication.UIInvokeAsync(oDel, null);
                                    if ((iX <= 0xbb8) && !string.IsNullOrEmpty(str))
                                    {
                                        Utilities.PlaySound(str, IntPtr.Zero, Utilities.SoundFlags.SND_FILENAME | Utilities.SoundFlags.SND_ASYNC | Utilities.SoundFlags.SND_NODEFAULT);
                                    }
                                    Thread.Sleep(0x3e8);
                                }
                            }
                            else
                            {
                                Thread.Sleep(iDelayMS);
                            }
                            FiddlerApplication.UIInvokeAsync( new UpdateUIDelegate(updateIt) , null);
                        };
                    }
                    worker.DoWork += handler;
                    worker.RunWorkerAsync();
                }
                else
                {
                    this._addScreenshotNow();
                    FiddlerApplication.UI.SetStatusText("A screenshot has been added to the capture.");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Screenshot failed");
            }
        }

            private void updateIt(){
                 FiddlerToolbar.SetScreenshotCounter("(cheese!)");
                                Application.DoEvents();
                                this.actCaptureScreenshot(0);
                                string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.sounds.Screenshot", CONFIG.GetPath("App") + "Screenshot.wav");
                                if (!string.IsNullOrEmpty(stringPref))
                                {
                                    Utilities.PlaySound(stringPref, IntPtr.Zero, Utilities.SoundFlags.SND_FILENAME | Utilities.SoundFlags.SND_ASYNC | Utilities.SoundFlags.SND_NODEFAULT);
                                }
                                FiddlerToolbar.SetScreenshotCounter(string.Empty);
                            
            }
        internal void actChangeToLayout(int iLayoutMode)
        {
            FiddlerApplication.Log.LogFormat("Switching to iLayoutMode: {0}", new object[] { iLayoutMode });
            FiddlerApplication.Prefs.SetInt32Pref("fiddler.ui.layout.mode", iLayoutMode);
            base.SuspendLayout();
            switch (iLayoutMode)
            {
                case 0:
                    this.miViewDefault.Checked = true;
                    this.miViewStacked.Checked = false;
                    this.miViewWide.Checked = false;
                    break;

                case 1:
                    this.miViewDefault.Checked = false;
                    this.miViewStacked.Checked = true;
                    this.miViewWide.Checked = false;
                    break;

                case 2:
                    this.miViewDefault.Checked = false;
                    this.miViewStacked.Checked = false;
                    this.miViewWide.Checked = true;
                    break;
            }
            if (iLayoutMode > 0)
            {
                this.lblSessions.Height = 0;
                this.pnlSessions.Dock = DockStyle.Top;
                this.splitterMain.Dock = DockStyle.Top;
                this.pnlSessions.Height = base.Height / 2;
                if (iLayoutMode == 1)
                {
                    this.tabsRequest.Dock = DockStyle.Top;
                    this.splitterInspector.Dock = DockStyle.Top;
                }
                else
                {
                    this.tabsRequest.Dock = DockStyle.Left;
                    this.splitterInspector.Dock = DockStyle.Left;
                }
                this.btnSquish.Visible = false;
                this.miViewSquish.Enabled = false;
            }
            else
            {
                this.lblSessions.Height = 14;
                this.pnlSessions.Dock = DockStyle.Left;
                this.splitterMain.Dock = DockStyle.Left;
                this.pnlSessions.Width = base.Width / 2;
                this.tabsRequest.Dock = DockStyle.Top;
                this.splitterInspector.Dock = DockStyle.Top;
                this.btnSquish.Visible = true;
                this.btnSquish.Text = "<<";
                this.miViewSquish.Enabled = true;
                this.miViewSquish.Checked = false;
            }
            base.ResumeLayout();
        }

        private static void actCheckForUpdates(bool verbose)
        {
            if (!CONFIG.bVersionCheckBlocked)
            {
                new Updater().CheckForUpdates(verbose);
            }
            else if (verbose)
            {
                FiddlerApplication.DoNotifyUser("Sorry, an Adminstrator has disabled the update check.", "I can't do that, Dave");
            }
        }

        private void actCheckForUpdatesQuiet()
        {
            actCheckForUpdates(false);
        }

        private void actCheckForUpdatesVerbose()
        {
            actCheckForUpdates(true);
        }

        [CodeDescription("Delete all cached WinINET files.")]
        public void actClearWinINETCache()
        {
            this.sbpInfo.Text = "Clearing WININET cache files...";
            Application.DoEvents();
            FiddlerApplication.UI.UseWaitCursor = true;
            WinINETCache.ClearFiles();
            FiddlerApplication.UI.UseWaitCursor = false;
            this.sbpInfo.Text = "WinINET Temporary Internet Files cache cleared.";
        }

        [CodeDescription("Delete all stored WinINET cookies; won't clear memory-only session cookies")]
        public void actClearWinINETCookies()
        {
            this.sbpInfo.Text = "Clearing WININET cookies...";
            Application.DoEvents();
            FiddlerApplication.UI.UseWaitCursor = true;
            WinINETCache.ClearCookies();
            FiddlerApplication.UI.UseWaitCursor = false;
            this.sbpInfo.Text = "WinINET cookies cleared.";
        }

        internal void actCommentSelectedSessions()
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                string sDefault = selectedSessions[0].oFlags["ui-comments"] ?? string.Empty;
                string str2 = frmPrompt.GetUserString("Enter Session Comment", "Enter a comment to associate with the selected session(s):", sDefault, true);
                if (str2 != null)
                {
                    this.lvSessions.BeginUpdate();
                    foreach (Session session in selectedSessions)
                    {
                        if (str2.Length > 0)
                        {
                            session.oFlags["ui-comments"] = str2;
                        }
                        else
                        {
                            session.oFlags.Remove("ui-comments");
                        }
                        if (session.ViewItem != null)
                        {
                            session.ViewItem.SubItems[9].Text = str2;
                        }
                    }
                    this.lvSessions.EndUpdate();
                }
            }
        }

        [CodeDescription("Detach Fiddler from WinINET.")]
        public void actDetachProxy()
        {
            if (FiddlerApplication.oProxy.Detach())
            {
                this.sbpCapture.Text = string.Empty;
                this.sbpCapture.Style = StatusBarPanelStyle.OwnerDraw;
            }
        }

        [CodeDescription("Compare two Web sessions using the default comparison tool.")]
        public void actDoCompareSessions(Session oSess1, Session oSess2)
        {
            string path = CONFIG.GetPath("SafeTemp");
            string str2 = path + @"\S1_" + oSess1.id.ToString() + ".txt";
            string str3 = path + @"\S2_" + oSess2.id.ToString() + ".txt";
            try
            {
                this.SaveFilesForDiffer(str2, str3, oSess1, oSess2);
            }
            catch (Exception exception)
            {
                FiddlerApplication.DoNotifyUser("Unable to save files for comparison.\n\n" + exception.Message, "Compare Failed", MessageBoxIcon.Hand);
                return;
            }
            try
            {
                string format = ((Control.ModifierKeys == Keys.Shift) || (Control.ModifierKeys == Keys.Alt)) ? FiddlerApplication.Prefs.GetStringPref("fiddler.differ.ParamsAlt", "\"{0}\" \"{1}\" -p") : FiddlerApplication.Prefs.GetStringPref("fiddler.differ.Params", " \"{0}\" \"{1}\"");
                using (Process.Start(CONFIG.GetPath("WINDIFF"), string.Format(format, str2, str3)))
                {
                }
            }
            catch (Exception exception2)
            {
                if (DialogResult.Yes == MessageBox.Show("Failed to launch comparison tool (" + exception2.Message + ").\n\nPlease ensure that " + CONFIG.GetPath("WINDIFF") + " is installed and in your Path.\n\nWould you like to download Windiff.exe?", "Compare Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
                {
                    Utilities.LaunchHyperlink(CONFIG.GetUrl("REDIR") + "GETWINDIFF");
                }
            }
        }

        private void actDoExport(Session[] oSelectedSessions)
        {
            string[] array = FiddlerApplication.oTranscoders.getExportFormats();
            if (array.Length > 0)
            {
                if (oSelectedSessions == null)
                {
                    oSelectedSessions = this.GetAllSessions();
                }
                Array.Sort<string>(array);
                string sExportFormat = actSelectImportExportFormat(false, array);
                if (sExportFormat != null)
                {
                    Application.DoEvents();
                    if (FiddlerApplication.DoExport(sExportFormat, oSelectedSessions, null, null))
                    {
                        this.sbpInfo.Text = "Export to " + sExportFormat + " completed.";
                    }
                    else
                    {
                        this.sbpInfo.Text = "Export failed or was cancelled.";
                    }
                }
            }
            else
            {
                FiddlerApplication.DoNotifyUser(string.Format("You can install Exporters from {0}FIDDLERTRANSCODERS", CONFIG.GetUrl("REDIR")), "No Exporters Installed");
            }
        }

        [CodeDescription("Launch the Find Sessions user experience.")]
        public void actDoFind()
        {
            frmSearch search = new frmSearch();
            search.cbSearchSelectedSessions.Enabled = this.lvSessions.SelectedCount > 0;
            search.cbSearchSelectedSessions.Checked = this.lvSessions.SelectedCount > 1;
            if (DialogResult.OK == search.ShowDialog(this))
            {
                IEnumerable selectedItems;
                int num = 0;
                if (search.cbSearchSelectedSessions.Checked)
                {
                    selectedItems = this.lvSessions.SelectedItems;
                }
                else
                {
                    selectedItems = this.lvSessions.Items;
                }
                System.Drawing.Color empty = System.Drawing.Color.Empty;
                if (search.cbxSearchColor.SelectedIndex > 0)
                {
                    empty = System.Drawing.Color.FromName(search.cbxSearchColor.Text);
                }
                if (search.cbSearchSelectMatches.Checked)
                {
                    FiddlerApplication.SuppressReportUpdates = true;
                    this.lvSessions.SelectedItems.Clear();
                    FiddlerApplication.SuppressReportUpdates = false;
                }
                string text = search.txtSearchFor.Text;
                Regex regex = null;
                if (search.txtSearchFor.Text.StartsWith("REGEX:", StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        RegexOptions options = RegexOptions.Singleline | RegexOptions.ExplicitCapture;
                        if (!search.cbSearchCaseSensitive.Checked)
                        {
                            options |= RegexOptions.IgnoreCase;
                        }
                        regex = new Regex(search.txtSearchFor.Text.Substring(6), options);
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show("An invalid regular expression was provided.\n" + exception.ToString(), "Invalid Regular Expression");
                    }
                }
                foreach (ListViewItem item in selectedItems)
                {
                    Session tag = item.Tag as Session;
                    if (tag != null)
                    {
                        bool success;
                        StringBuilder builder = new StringBuilder();
                        if (((search.cbxSearchIn.SelectedIndex < 2) && (tag.oRequest != null)) && (tag.oRequest.headers != null))
                        {
                            if (search.cbxExamine.SelectedIndex < 2)
                            {
                                builder.Append(tag.oRequest.headers.ToString(true, false, true));
                            }
                            if ((((search.cbxExamine.SelectedIndex != 1) && (tag.requestBodyBytes != null)) && (tag.requestBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oRequest["Content-Type"])))
                            {
                                if (search.cbSearchDecodeFirst.Checked)
                                {
                                    tag.utilDecodeRequest();
                                }
                                builder.Append(Utilities.getEntityBodyEncoding(tag.oRequest.headers, tag.requestBodyBytes).GetString(tag.requestBodyBytes));
                            }
                        }
                        if (((search.cbxSearchIn.SelectedIndex == 0) || (search.cbxSearchIn.SelectedIndex == 2)) && ((tag.oResponse != null) && (tag.oResponse.headers != null)))
                        {
                            if (search.cbxExamine.SelectedIndex != 2)
                            {
                                builder.Append(tag.oResponse.headers.ToString(true, false));
                            }
                            if ((((search.cbxExamine.SelectedIndex != 1) && (tag.responseBodyBytes != null)) && (tag.responseBodyBytes.Length > 0)) && (search.cbSearchBinaries.Checked || !Utilities.IsBinaryMIME(tag.oResponse["Content-Type"])))
                            {
                                if (search.cbSearchDecodeFirst.Checked)
                                {
                                    tag.utilDecodeResponse();
                                }
                                builder.Append(Utilities.getResponseBodyEncoding(tag).GetString(tag.responseBodyBytes));
                            }
                        }
                        if (3 == search.cbxSearchIn.SelectedIndex)
                        {
                            builder.Append(tag.fullUrl);
                        }
                        string input = builder.ToString();
                        if (regex != null)
                        {
                            success = regex.Match(input).Success;
                        }
                        else
                        {
                            success = -1 < input.IndexOf(text, search.cbSearchCaseSensitive.Checked ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase);
                        }
                        if (success)
                        {
                            num++;
                            if (num == 1)
                            {
                                item.EnsureVisible();
                            }
                            if (empty != System.Drawing.Color.Empty)
                            {
                                if ((tag.oFlags["ui-bold"] != "user-marked") && (item.ForeColor != System.Drawing.Color.Black))
                                {
                                    tag.oFlags["ui-oldcolor"] = Utilities.GetStringFromColor(item.ForeColor);
                                }
                                item.BackColor = empty;
                                tag.oFlags["ui-backcolor"] = search.cbxSearchColor.Text;
                            }
                            if (search.cbSearchSelectMatches.Checked)
                            {
                                item.Selected = true;
                            }
                        }
                        else if (search.cbUnmarkOld.Checked && (tag.oFlags["ui-backcolor"] == search.cbxSearchColor.Text))
                        {
                            item.BackColor = this.lvSessions.BackColor;
                            tag.oFlags.Remove("ui-backcolor");
                        }
                    }
                }
                string str3 = "contained";
                if (regex != null)
                {
                    str3 = "matched";
                }
                this.sbpInfo.Text = string.Format("{0} session{1} {2} '{3}'", new object[] { num, (num != 1) ? "s" : string.Empty, str3, (regex == null) ? text : text.Substring(6) });
                this.lvSessions.Focus();
            }
            search.Dispose();
        }

        public void actExit()
        {
            base.Close();
        }

        internal void actGetHelp()
        {
            Utilities.LaunchHyperlink(CONFIG.GetUrl("HelpContents") + Application.ProductVersion);
        }

        private void actInspectInNewWindow()
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                firstSelectedSession.actInspectInNewWindow();
            }
        }

        [CodeDescription("Show the most relevant Request and Response inspectors for this session")]
        public void actInspectSession()
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (((firstSelectedSession != null) && (firstSelectedSession.ViewItem != null)) && FiddlerApplication.DoBeforeInspect(firstSelectedSession))
            {
                string sName = "HEADERS";
                string str2 = "TEXTVIEW";
                TabPage key = null;
                TabPage page2 = null;
                try
                {
                    string stringPref = FiddlerApplication.Prefs.GetStringPref("fiddler.ui.inspectors.request.alwaysuse", null);
                    if (!string.IsNullOrEmpty(stringPref))
                    {
                        sName = stringPref;
                    }
                    else if ((((firstSelectedSession.oRequest != null) && (firstSelectedSession.oRequest.headers != null)) && (!firstSelectedSession.isTunnel && (FiddlerApplication.oInspectors != null))) && ((firstSelectedSession.requestBodyBytes != null) && (firstSelectedSession.requestBodyBytes.Length > 0)))
                    {
                        DictionaryEntry entry = FiddlerApplication.oInspectors.FindBestRequestInspector(firstSelectedSession);
                        if (entry.Key != null)
                        {
                            key = (TabPage)entry.Key;
                        }
                    }
                    string str4 = FiddlerApplication.Prefs.GetStringPref("fiddler.ui.inspectors.response.alwaysuse", null);
                    if (!string.IsNullOrEmpty(str4))
                    {
                        str2 = str4;
                    }
                    else if ((firstSelectedSession.oResponse != null) && (firstSelectedSession.oResponse.headers != null))
                    {
                        if (((firstSelectedSession.isTunnel || (firstSelectedSession.responseBodyBytes == null)) || (firstSelectedSession.responseBodyBytes.Length < 1)) || (((firstSelectedSession.responseCode != 200) && (firstSelectedSession.responseCode != 0xcf)) && (firstSelectedSession.responseCode < 0x194)))
                        {
                            str2 = "HEADERS";
                        }
                        else if (firstSelectedSession.oResponse.headers.Exists("Content-Encoding"))
                        {
                            str2 = "TRANSFORMER";
                        }
                        else if (((firstSelectedSession.responseCode >= 200) && (firstSelectedSession.responseCode < 300)) && (FiddlerApplication.oInspectors != null))
                        {
                            DictionaryEntry entry2 = FiddlerApplication.oInspectors.FindBestResponseInspector(firstSelectedSession);
                            if (entry2.Key != null)
                            {
                                page2 = (TabPage)entry2.Key;
                            }
                        }
                    }
                    else
                    {
                        str2 = "HEADERS";
                    }
                }
                catch (Exception exception)
                {
                    FiddlerApplication.ReportException(exception);
                }
                this.tabsViews.SelectedTab = this.pageInspector;
                if (key != null)
                {
                    this.tabsRequest.SelectedTab = key;
                }
                else
                {
                    Utilities.activateTabByTitle(sName, this.tabsRequest);
                }
                if (page2 != null)
                {
                    this.tabsResponse.SelectedTab = page2;
                }
                else
                {
                    Utilities.activateTabByTitle(str2, this.tabsResponse);
                }
                if ((this._frmFloatingInspectors != null) && (this._frmFloatingInspectors.WindowState == FormWindowState.Minimized))
                {
                    this._frmFloatingInspectors.WindowState = FormWindowState.Normal;
                }
            }
        }

        [CodeDescription("Unselects all selected sessions, Selects all unselected sessions")]
        public void actInvertSelectedSessions()
        {
            this.lvSessions.BeginUpdate();
            FiddlerApplication.SuppressReportUpdates = true;
            foreach (ListViewItem item in this.lvSessions.Items)
            {
                item.Selected = !item.Selected;
            }
            this.lvSessions.EndUpdate();
            FiddlerApplication.SuppressReportUpdates = false;
            this.actUpdateInspector(true, true);
        }

        [CodeDescription("Display the named RequestInspector object")]
        public void ActivateRequestInspector(string sName)
        {
            this.tabsViews.SelectedTab = this.pageInspector;
            Utilities.activateTabByTitle(sName, this.tabsRequest);
        }

        [CodeDescription("Display the named ResponseInspector object")]
        public void ActivateResponseInspector(string sName)
        {
            this.tabsViews.SelectedTab = this.pageInspector;
            Utilities.activateTabByTitle(sName, this.tabsResponse);
        }

        [CodeDescription("Display the named tab from the top-level View")]
        public void ActivateView(string sViewTabName)
        {
            Utilities.activateTabByTitle(sViewTabName, this.tabsViews);
        }

        [CodeDescription("Launch the Internet Explorer Control Panel Connections dialog.")]
        public void actLaunchIEProxy()
        {
            Utilities.RunExecutable("rundll32.exe", "shell32.dll,Control_RunDLL inetcpl.cpl,,4");
        }

        public void actLoadScripts()
        {
            this.UpdateLoadFromCbx();
            if (FiddlerApplication.scriptRules != null)
            {
                FiddlerApplication.scriptRules.LoadRulesScript();
            }
        }

        [CodeDescription("Load the specified .SAZ or .ZIP session archive")]
        public bool actLoadSessionArchive(string sFilename)
        {
            bool flag;
            sFilename = Utilities.EnsurePathIsAbsolute(CONFIG.GetPath("Captures"), sFilename);
            if (!System.IO.File.Exists(sFilename))
            {
                FiddlerApplication.Log.LogFormat("File Not Found attempting to load session archive {0}", new object[] { sFilename });
                return false;
            }
            string destFileName = null;
            string sourceFileName = null;
            if (sFilename.StartsWith(@"\\"))
            {
                try
                {
                    this.sbpInfo.Text = "Buffering .SAZ locally...";
                    Application.DoEvents();
                    sourceFileName = sFilename;
                    destFileName = Path.GetTempFileName();
                    System.IO.File.Copy(sourceFileName, destFileName, true);
                    sFilename = destFileName;
                }
                catch (Exception exception)
                {
                    FiddlerApplication.DoNotifyUser("Could not copy the SAZ File locally. " + Utilities.DescribeException(exception), "Operation Failed", MessageBoxIcon.Hand);
                    return false;
                }
            }
            ZipArchive archive = null;
            string comment = string.Empty;
            string str4 = string.Empty;
            try
            {
                this.sbpInfo.Text = "Reading archive...";
                Application.DoEvents();
                using (FileStream stream = System.IO.File.Open(sFilename, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    if (((stream.Length < 0x40L) || (stream.ReadByte() != 80)) || (stream.ReadByte() != 0x4b))
                    {
                        FiddlerApplication.DoNotifyUser("The selected file is not a Fiddler-generated .SAZ archive of HTTP Sessions.", "Invalid Archive", MessageBoxIcon.Hand);
                        if ((destFileName != null) && System.IO.File.Exists(destFileName))
                        {
                            System.IO.File.Delete(destFileName);
                        }
                        return false;
                    }
                }
                archive = new ZipArchive(new DiskFile(sFilename));
                archive.BeginUpdate();
                AbstractFolder folder = archive.GetFolder("raw");
                if (!folder.Exists)
                {
                    FiddlerApplication.DoNotifyUser("The selected file is not a Fiddler-generated .SAZ archive of HTTP Sessions.", "Invalid Archive", MessageBoxIcon.Hand);
                    archive.EndUpdate();
                    archive = null;
                    if ((destFileName != null) && System.IO.File.Exists(destFileName))
                    {
                        System.IO.File.Delete(destFileName);
                    }
                    return false;
                }
                this.lvSessions.BeginUpdate();
                AbstractFile[] files = folder.GetFiles(false, new object[] { "*_c.txt" });
                this.sbpInfo.Text = "Reading archive (" + files.Length + " sessions)...";
                comment = archive.Comment;
                Application.DoEvents();
                foreach (ZippedFile file in files)
                {
                    try
                    {
                        Stream stream2;
                        byte[] buffer2;
                        byte[] arrBytes = new byte[file.Size];
                    Label_0204:
                        try
                        {
                            stream2 = file.OpenRead(FileShare.Read);
                        }
                        catch (InvalidDecryptionPasswordException)
                        {
                            if (string.IsNullOrEmpty(str4))
                            {
                                str4 = string.Format("\tEncryption: {0} ({1}bit)\r\n", file.EncryptionMethod.ToString(), file.EncryptionStrength.ToString());
                            }
                            string str5 = frmPrompt.GetUserString("Password-Protected Session Archive", "Enter the password (case-sensitive) that will be used to decrypt this session archive file. Leave blank to abort open.", string.Empty);
                            if (str5.Length > 0)
                            {
                                archive.DefaultDecryptionPassword = str5;
                                goto Label_0204;
                            }
                            this.sbpInfo.Text = "Aborted archive load.";
                            this.lvSessions.EndUpdate();
                            return false;
                        }
                        Utilities.ReadEntireStream(stream2, arrBytes);
                        stream2.Close();
                        AbstractFile file2 = folder.GetFile(file.Name.Replace("_c.txt", "_s.txt"));
                        if (!file2.Exists)
                        {
                            buffer2 = null;
                        }
                        else
                        {
                            buffer2 = new byte[file2.Size];
                            stream2 = file2.OpenRead();
                            Utilities.ReadEntireStream(stream2, buffer2);
                            stream2.Close();
                        }
                        file2 = null;
                        AbstractFile file3 = folder.GetFile(file.Name.Replace("_c.txt", "_m.xml"));
                        Session oS = this.AddReportedSession(arrBytes, buffer2, file3.Exists ? file3.OpenRead() : null, SessionFlags.LoadedFromSAZ);
                        if (oS.isAnyFlagSet(SessionFlags.IsWebSocketTunnel) && !oS.HTTPMethodIs("CONNECT"))
                        {
                            AbstractFile file4 = folder.GetFile(file.Name.Replace("_c.txt", "_w.txt"));
                            if (file4.Exists)
                            {
                                WebSocket.LoadWebSocketMessagesFromStream(oS, file4.OpenRead());
                            }
                            else
                            {
                                oS.oFlags["X-WS-SAZ"] = "SAZ File did not contain any WebSocket messages.";
                            }
                        }
                    }
                    catch (Exception exception2)
                    {
                        FiddlerApplication.DoNotifyUser("Invalid data was present for session [" + Utilities.TrimAfter(file.Name, "_") + "].\n\n" + Utilities.DescribeException(exception2) + "\n" + exception2.StackTrace, "Archive Incomplete", MessageBoxIcon.Hand);
                    }
                }
                files = null;
                if (sourceFileName != null)
                {
                    FiddlerApplication.Log.LogFormat("Archived sessions loaded from:\r\n\t{0}\r\n\tBuffered Locally as: {1}\r\n\t{2}\r\n{3}", new object[] { sourceFileName, destFileName, comment, str4 });
                    this.sbpInfo.Text = string.Format("Archived sessions loaded from {0}.", sourceFileName);
                }
                else
                {
                    FiddlerApplication.Log.LogFormat("Archived sessions loaded from:\r\n\t{0}\r\n\t{1}\r\n{2}", new object[] { sFilename, comment, str4 });
                    this.sbpInfo.Text = string.Format("Archived sessions loaded from {0}.", sFilename);
                }
                flag = true;
            }
            catch (Exception exception3)
            {
                FiddlerApplication.DoNotifyUser(string.Concat(new object[] { "The Session Archive File could not be loaded. The file may be corrupt; try redownloading or recreating it.\n\n", exception3.Message, "\n", exception3.StackTrace, "\n\n", exception3.InnerException, "\n" }), "Corrupt Archive", MessageBoxIcon.Hand);
                this.sbpInfo.Text = "Failed to load archive.";
                flag = false;
            }
            this.lvSessions.EndUpdate();
            Application.DoEvents();
            if (archive != null)
            {
                archive.EndUpdate();
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.saz.ClearCaches", false))
                {
                    ZipArchive.ClearCachedZipHandlers();
                }
                archive = null;
            }
            if ((destFileName != null) && System.IO.File.Exists(destFileName))
            {
                System.IO.File.Delete(destFileName);
            }
            if (CONFIG.bIsViewOnly)
            {
                FiddlerToolbar.SetViewerTitle(Path.GetFileNameWithoutExtension(sourceFileName ?? sFilename), sourceFileName ?? sFilename);
            }
            if (flag)
            {
                this.oSAZMRU.PushFile(sourceFileName ?? sFilename);
            }
            return flag;
        }

        public void actMinimizeToTray()
        {
            this.notifyIcon.Visible = true;
            base.Visible = false;
        }

        private void actPasteDataURIFromClipboard()
        {
            try
            {
                string text = Clipboard.GetText();
                if (text.IndexOf("data:", 0, Math.Min(text.Length, 0x40)) >= 0)
                {
                    string sString = Utilities.TrimBefore(text, "data:");
                    string str3 = Utilities.TrimAfter(sString, ',');
                    string str4 = Utilities.TrimBefore(sString, ',');
                    string str5 = Utilities.TrimBefore(str3, ';');
                    string str6 = Utilities.TrimAfter(str3, ';');
                    bool flag = false;
                    if (str5.Contains("base64"))
                    {
                        flag = true;
                    }
                    if (str4.Length < 1)
                    {
                        MessageBox.Show("The DataURI did not contain any data", "Malformed URI");
                    }
                    else
                    {
                        byte[] buffer3;
                        HTTPRequestHeaders headers = new HTTPRequestHeaders();
                        headers.HTTPMethod = "GET";
                        headers.Add("Host", "localhost");
                        headers.RequestPath = (str4.Length > 15) ? string.Format("/datauri/{0}~{1}", Utilities.UrlPathEncode(Utilities.TrimTo(str4, 10)), Utilities.UrlPathEncode(str4.Substring(str4.Length - 10))) : string.Format("/datauri/{0}", Utilities.UrlPathEncode(str4));
                        byte[] arrRequest = headers.ToByteArray(true, true, false);
                        byte[] bytes = Encoding.UTF8.GetBytes(string.Format("HTTP/1.1 200 OK\r\nContent-Type: {0}\r\nCache-Control: max-age=0, must-revalidate\r\nConnection: close\r\n\r\n", str6));
                        if (flag)
                        {
                            buffer3 = Convert.FromBase64String(Utilities.TrimAfter(Utilities.TrimAfter(str4, '\''), '"').Trim());
                        }
                        else
                        {
                            buffer3 = Encoding.UTF8.GetBytes(str4);
                        }
                        MemoryStream stream = new MemoryStream();
                        stream.Write(bytes, 0, bytes.Length);
                        stream.Write(buffer3, 0, buffer3.Length);
                        Session oSession = new Session(arrRequest, stream.ToArray(), SessionFlags.ServedFromCache | SessionFlags.ImportedFromOtherTool | SessionFlags.ResponseGeneratedByFiddler | SessionFlags.RequestGeneratedByFiddler);
                        oSession.state = SessionStates.Done;
                        this.finishSession(oSession);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Unable to interpret DataURI");
            }
        }

        private void actPasteFilesFromClipboard()
        {
            string[] data = (string[])Clipboard.GetData("FileDrop");
            if (data != null)
            {
                foreach (string str in data)
                {
                    if (Directory.Exists(str))
                    {
                        this.CreateSessionsForFolder(str);
                    }
                    else
                    {
                        this.CreateSessionsForFile(str, string.Empty);
                    }
                }
            }
        }

        private void actPasteImageFromClipboard()
        {
            try
            {
                Image image = Clipboard.GetImage();
                if (image == null)
                {
                    MessageBox.Show("The clipboard did not contain an image", "Nothing to do");
                }
                else
                {
                    HTTPRequestHeaders headers = new HTTPRequestHeaders();
                    headers.HTTPMethod = "GET";
                    headers.Add("Host", "localhost");
                    headers.RequestPath = string.Format("/clipboard/{0}.png", DateTime.Now.ToString("H-mm-ss"));
                    byte[] arrRequest = headers.ToByteArray(true, true, false);
                    byte[] bytes = Encoding.UTF8.GetBytes("HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nCache-Control: max-age=0, must-revalidate\r\nConnection: close\r\n\r\n");
                    MemoryStream stream = new MemoryStream();
                    stream.Write(bytes, 0, bytes.Length);
                    image.Save(stream, ImageFormat.Png);
                    Session oSession = new Session(arrRequest, stream.ToArray(), SessionFlags.ServedFromCache | SessionFlags.ImportedFromOtherTool | SessionFlags.ResponseGeneratedByFiddler | SessionFlags.RequestGeneratedByFiddler);
                    oSession.state = SessionStates.Done;
                    this.finishSession(oSession);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Unable to store image.");
            }
        }

        [CodeDescription("Passes sCommand into the QuickExec command-processing pipeline")]
        public bool actQuickExec(string sCommand)
        {
            if (string.IsNullOrEmpty(sCommand))
            {
                return false;
            }
            return this.txtExec_OnExecute(sCommand);
        }

        public void actRefreshInspectorsIfNeeded(Session oSession)
        {
            if (oSession == this.GetFirstSelectedSession())
            {
                this.actUpdateInspector(true, true);
            }
        }

        public void actRefreshUI()
        {
            if (!FiddlerApplication.isClosing)
            {
                int selectedCount = this.lvSessions.SelectedCount;
                this.actUpdateInspector(true, true);
                this.actReportStatistics();
                if (selectedCount == 1)
                {
                    Session firstSelectedSession = this.GetFirstSelectedSession();
                    if (firstSelectedSession == null)
                    {
                        this.sbpInfo.Text = string.Empty;
                    }
                    else if (SessionStates.ReadingResponse == firstSelectedSession.state)
                    {
                        if (firstSelectedSession.oResponse["Content-Length"] != string.Empty)
                        {
                            long num2;
                            if (long.TryParse(firstSelectedSession.oResponse["Content-Length"], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out num2))
                            {
                                this.sbpInfo.Text = string.Format("Download Progress: {0:N0} of {1:N0} bytes. Hit F5 to refresh.", firstSelectedSession.oResponse._PeekDownloadProgress, num2);
                            }
                            else
                            {
                                this.sbpInfo.Text = "Reading server response...";
                            }
                        }
                        else
                        {
                            this.sbpInfo.Text = string.Format("Download Progress: {0:N0} bytes. Hit F5 to refresh.", firstSelectedSession.oResponse._PeekDownloadProgress);
                        }
                    }
                    else if (SessionStates.ReadingRequest == firstSelectedSession.state)
                    {
                        if (firstSelectedSession.oRequest["Content-Length"] != string.Empty)
                        {
                            long num3;
                            if (long.TryParse(firstSelectedSession.oRequest["Content-Length"], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out num3))
                            {
                                this.sbpInfo.Text = string.Format("Upload Progress: {0:N0} of {1:N0} bytes. Hit F5 to refresh.", firstSelectedSession.oRequest._PeekUploadProgress, num3);
                            }
                            else
                            {
                                this.sbpInfo.Text = "Reading client request...";
                            }
                        }
                        else
                        {
                            this.sbpInfo.Text = string.Format("Upload Progress: {0:N0} bytes. Hit F5 to refresh.", firstSelectedSession.oRequest._PeekUploadProgress);
                        }
                    }
                    else if (firstSelectedSession.isAnyFlagSet(SessionFlags.IsWebSocketTunnel | SessionFlags.IsBlindTunnel))
                    {
                        string str = string.Format(" Raw Bytes Out: {0:N0}; In: {1:N0}", firstSelectedSession.TunnelEgressByteCount, firstSelectedSession.TunnelIngressByteCount);
                        this.sbpInfo.Text = string.Format("This {0} a {1} tunnel to '{2}:{3}'.{4}", new object[] { firstSelectedSession.TunnelIsOpen ? "is" : "was", firstSelectedSession.isFlagSet(SessionFlags.IsWebSocketTunnel) ? "WebSocket" : "CONNECT", firstSelectedSession.hostname, firstSelectedSession.port, str });
                    }
                    else if (firstSelectedSession.isFlagSet(SessionFlags.IsDecryptingTunnel))
                    {
                        this.sbpInfo.Text = string.Format("This is a HTTPS Decrypting tunnel to '{0}:{1}'.", firstSelectedSession.hostname, firstSelectedSession.port);
                    }
                    else
                    {
                        this.sbpInfo.Text = firstSelectedSession.fullUrl;
                    }
                }
                else
                {
                    this.sbpInfo.Text = string.Empty;
                }
            }
        }

        [CodeDescription("Reissue the selected requests, optionally breaking on each request. If SHIFT key is held down, user will be prompted for repeat count")]
        public void actReissueSelected(bool bBreakOnRequest)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                int result = 1;
                if (Keys.Shift == (Control.ModifierKeys & Keys.Shift))
                {
                    string s = frmPrompt.GetUserString("Repeat Count", "Repeat this request how many times?", "5", true);
                    if (s == null)
                    {
                        return;
                    }
                    if (!int.TryParse(s, out result))
                    {
                        return;
                    }
                }
                StringDictionary oNewFlags = new StringDictionary();
                if (bBreakOnRequest)
                {
                    oNewFlags.Add("x-breakrequest", "ReissueAndBreak");
                    oNewFlags.Add("x-Builder-Inspect", "1");
                }
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.reissue.autoauth", true))
                {
                    oNewFlags.Add("x-AutoAuth", "(default)");
                }
                if (FiddlerApplication.Prefs.GetInt32Pref("fiddler.reissue.autoredircount", 0) > 0)
                {
                    oNewFlags.Add("x-Builder-MaxRedir", FiddlerApplication.Prefs.GetInt32Pref("fiddler.reissue.autoredircount", 0).ToString());
                }
                for (int i = 0; i < result; i++)
                {
                    for (int j = 0; j < selectedSessions.Length; j++)
                    {
                        if ((selectedSessions[j].oRequest != null) && (selectedSessions[j].oRequest.headers != null))
                        {
                            FiddlerApplication.oProxy.SendRequest(selectedSessions[j].oRequest.headers, selectedSessions[j].requestBodyBytes, oNewFlags);
                        }
                    }
                }
            }
        }

        [CodeDescription("Reload all inspector objects")]
        public void actReloadInspectors()
        {
            FiddlerApplication.oInspectors.Dispose();
            FiddlerApplication.oInspectors = new Inspectors(this.tabsRequest, this.tabsResponse, this);
        }

        public void actRemoveAllSessions()
        {
            if (CONFIG.bResetCounterOnClear)
            {
                Session.ResetSessionCounter();
            }
            this.lvSessions.BeginUpdate();
            FiddlerApplication.SuppressReportUpdates = true;
            this.lvSessions.Items.Clear();
            this.sbpInfo.Text = string.Empty;
            this.lvSessions.EndUpdate();
            FiddlerApplication.SuppressReportUpdates = false;
            this.actUpdateInspector(true, true);
            FiddlerApplication.oProxy.PurgeServerPipePool();
            UINotifyList.ClearAllErrors();
        }

        [CodeDescription("Remove all selected sessions.")]
        public void actRemoveSelectedSessions()
        {
            int selectedCount = this.lvSessions.SelectedCount;
            if (selectedCount >= 1)
            {
                if (selectedCount == this.lvSessions.Items.Count)
                {
                    this.actRemoveAllSessions();
                }
                else
                {
                    ListView.SelectedListViewItemCollection selectedItems = this.lvSessions.SelectedItems;
                    this.lvSessions.BeginUpdate();
                    FiddlerApplication.SuppressReportUpdates = true;
                    foreach (ListViewItem item in selectedItems)
                    {
                        item.Remove();
                    }
                    this.sbpInfo.Text = string.Empty;
                    if (this.lvSessions.FocusedItem != null)
                    {
                        this.lvSessions.FocusedItem.Selected = true;
                    }
                    this.lvSessions.EndUpdate();
                    FiddlerApplication.SuppressReportUpdates = false;
                    this.actUpdateInspector(true, true);
                }
            }
        }

        [CodeDescription("Remove Sessions which are not selected")]
        public void actRemoveUnselectedSessions()
        {
            this.lvSessions.BeginUpdate();
            FiddlerApplication.SuppressReportUpdates = true;
            foreach (ListViewItem item in this.lvSessions.Items)
            {
                if (!item.Selected)
                {
                    item.Remove();
                }
            }
            this.lvSessions.EndUpdate();
            FiddlerApplication.SuppressReportUpdates = false;
            this.actUpdateInspector(true, true);
        }

        public void actReportStatistics()
        {
            this.actReportStatistics(false);
        }

        public void actReportStatistics(bool bImmediate)
        {
            this.UpdateStatusBar(false);
            if (!FiddlerApplication.SuppressReportUpdates)
            {
                if (bImmediate)
                {
                    this.actUpdateReport();
                }
                else if (!oReportingQueueTimer.Enabled)
                {
                    oReportingQueueTimer.Start();
                }
            }
        }

        public void actRestoreWindow()
        {
            if (Utilities.IsIconic(base.Handle))
            {
                Utilities.ShowWindowAsync(base.Handle, 9);
            }
            if (!CONFIG.bAlwaysShowTrayIcon)
            {
                this.notifyIcon.Visible = false;
            }
            base.Visible = true;
            Utilities.SetForegroundWindow(base.Handle);
        }

        [CodeDescription("Immediately resume all paused sessions.")]
        public void actResumeAllSessions()
        {
            this.pnlSessionControls.Visible = false;
            foreach (Session session in this.GetAllSessions())
            {
                if (session != null)
                {
                    if ((session.state == SessionStates.HandTamperRequest) && (session.ViewItem != null))
                    {
                        session.ViewItem.ImageIndex = 0;
                    }
                    if ((session.state == SessionStates.HandTamperResponse) && (session.ViewItem != null))
                    {
                        session.ViewItem.ImageIndex = 2;
                    }
                    session.ThreadResume();
                }
            }
        }

        internal void actSaveAllSessions()
        {
            Session[] allSessions = this.GetAllSessions();
            this.actSaveSessionArchive(allSessions);
        }

        private void actSaveAndOpenResponseBodies()
        {
            bool flag = Control.ModifierKeys == Keys.Control;
            if (flag)
            {
                Application.DoEvents();
            }
            bool flag2 = false;
            foreach (Session session in this.GetSelectedSessions())
            {
                if ((session.responseBodyBytes != null) && (0L < session.responseBodyBytes.LongLength))
                {
                    try
                    {
                        string sFilename = Utilities.EnsureUniqueFilename(string.Format(@"{0}\{1}", Environment.GetFolderPath(Environment.SpecialFolder.Desktop), session.SuggestedFilename));
                        session.utilDecodeResponse();
                        session.SaveResponseBody(sFilename);
                        flag2 = true;
                        if (flag)
                        {
                            Utilities.DoOpenFileWith(sFilename);
                        }
                        else
                        {
                            using (Process.Start(sFilename))
                            {
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        FiddlerApplication.ReportException(exception, "Unable to open response", "Attempting to open the response body resulted in an error.");
                    }
                }
            }
            if (!flag2)
            {
                FiddlerApplication.DoNotifyUser("None of the selected sessions contained a response body.", "Nothing to do");
            }
        }

        [CodeDescription("Launch the Save Headers to Single File feature.")]
        public void actSaveHeaders()
        {
            if (this.lvSessions.SelectedCount >= 1)
            {
                this.dlgSaveBinary.Title = "Save headers to one text file";
                this.dlgSaveBinary.FileName = this.GetFirstSelectedSession().id.ToString() + "_Headers.txt";
                if (DialogResult.OK == this.dlgSaveBinary.ShowDialog(this))
                {
                    this.actSaveSessions(this.dlgSaveBinary.FileName, true);
                }
            }
        }

        [CodeDescription("Launch the Save Selected Requests feature.")]
        public void actSaveRequests()
        {
            this.dlgSaveBinary.Title = "Save requests to...";
            foreach (Session session in this.GetSelectedSessions())
            {
                this.dlgSaveBinary.FileName = session.id.ToString() + "_Request.txt";
                if (DialogResult.OK != this.dlgSaveBinary.ShowDialog(this))
                {
                    break;
                }
                session.SaveRequest(this.dlgSaveBinary.FileName, false);
            }
        }

        [CodeDescription("Launch the Save Selected Responses feature.")]
        public void actSaveResponses()
        {
            this.dlgSaveBinary.Title = "Save responses to...";
            foreach (Session session in this.GetSelectedSessions())
            {
                this.dlgSaveBinary.FileName = session.id.ToString() + "_Response.txt";
                if (DialogResult.OK != this.dlgSaveBinary.ShowDialog(this))
                {
                    break;
                }
                session.SaveResponse(this.dlgSaveBinary.FileName, false);
            }
            this.UpdateLoadFromCbx();
        }

        private void actSaveSessionArchive(Session[] arrSessions)
        {
            if (DialogResult.OK == this.dlgSaveZip.ShowDialog(this))
            {
                string fileName = this.dlgSaveZip.FileName;
                if (this.dlgSaveZip.FilterIndex == 2)
                {
                    string sTitle = !CONFIG.bUseAESForSAZ ? "Password-Protect SAZ (Weak Encryption)" : (FiddlerApplication.Prefs.GetBoolPref("fiddler.saz.AES.Use256Bit", false) ? "Password-Protect SAZ (256-bit AES)" : "Password-Protect SAZ (128-bit AES)");
                    string sPassword = frmPrompt.GetUserString(sTitle, "Enter the password (case-sensitive) that will be used to encrypt this session archive file. Leave blank for no password.", string.Empty, true);
                    if (sPassword == null)
                    {
                        return;
                    }
                    if (sPassword.Length > 0)
                    {
                        this.actSaveSessionArchive(fileName, sPassword, arrSessions);
                        return;
                    }
                }
                this.actSaveSessionArchive(fileName, null, arrSessions);
            }
        }

        private void actSaveSessionArchive(string sFilename, string sPassword, Session[] arrSessions)
        {
            try
            {
                if (System.IO.File.Exists(sFilename))
                {
                    System.IO.File.Delete(sFilename);
                }
                this.sbpInfo.Text = "Archiving...";
                Application.DoEvents();
                DiskFile zipFile = new DiskFile(sFilename);
                ZipArchive archive = new ZipArchive(zipFile);
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.SAZ.UseMemoryCache", true))
                {
                    archive.TempFolder = new MemoryFolder();
                }
                StringBuilder sbHTML = new StringBuilder(0x200);
                sbHTML.Append("<html><head><style>body,thead,td,a,p{font-family:verdana,sans-serif;font-size: 10px;}</style></head><body><table cols=" + ((this.lvSessions.Columns.Count + 1)).ToString() + "><thead><tr>");
                sbHTML.Append("<th>&nbsp;</th>");
                foreach (ColumnHeader header in this.lvSessions.Columns)
                {
                    sbHTML.AppendFormat("<th>{0}</th>", Utilities.HtmlEncode(header.Text));
                }
                sbHTML.Append("</tr></thead><tbody>");
                archive.BeginUpdate();
                ZippedFolder folder1 = (ZippedFolder)archive.CreateFolder("raw");
                if (!string.IsNullOrEmpty(sPassword))
                {
                    if (CONFIG.bUseAESForSAZ)
                    {
                        archive.DefaultEncryptionMethod = EncryptionMethod.WinZipAes;
                        if (!FiddlerApplication.Prefs.GetBoolPref("fiddler.saz.AES.Use256Bit", false))
                        {
                            archive.DefaultEncryptionStrength = 0x80;
                        }
                    }
                    archive.DefaultEncryptionPassword = sPassword;
                }
                archive.Comment = "Fiddler (v" + Application.ProductVersion + ") Session Archive. See http://www.fiddler2.com";
                int num = 1;
                int length = arrSessions.Length;
                string sFileNumberFormat = "D" + length.ToString().Length;
                foreach (Session session in arrSessions)
                {
                    this.sbpInfo.Text = string.Format("Collecting data... #{0} (ID:{1})", num, session.id);
                    Application.DoEvents();
                    Utilities.WriteSessionToSAZ(session, zipFile, num, sFileNumberFormat, sbHTML, true);
                    num++;
                }
                sbHTML.Append("</tbody></table></body></html>");
                ZippedFile file2 = new ZippedFile(zipFile, @"\_index.htm");
                StreamWriter writer = new StreamWriter(file2.CreateWrite(FileShare.None), Encoding.UTF8);
                writer.Write(sbHTML.ToString());
                writer.Close();
                Utilities.WriteODCXML(zipFile);
                this.sbpInfo.Text = "Finalizing archive...";
                Application.DoEvents();
                try
                {
                    archive.EndUpdate();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString(), "ZIP Creation Error");
                }
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.saz.ClearCaches", false))
                {
                    ZipArchive.ClearCachedZipHandlers();
                }
                this.sbpInfo.Text = "Saved Session Archive: " + sFilename;
                try
                {
                    object[] args = new object[] { sFilename, (new FileInfo(sFilename).Length / 0x400L).ToString("N0"), (num - 1).ToString("N0"), string.IsNullOrEmpty(sPassword) ? string.Empty : string.Format("\tEncryption: {0} ({1}bit)\n", archive.DefaultEncryptionMethod, archive.DefaultEncryptionStrength) };
                    string sMsg = string.Format("Sessions archived to:\n\tFilename: {0}\n\tFile size: {1}kb\n\tSession count: {2}\n{3}", args);
                    FiddlerApplication.Log.LogString(sMsg);
                    this.oSAZMRU.PushFile(sFilename);
                }
                catch (Exception exception2)
                {
                    FiddlerApplication.ReportException(exception2);
                }
                Application.DoEvents();
            }
            catch (Exception exception3)
            {
                FiddlerApplication.DoNotifyUser("Failed to save Session Archive.\n\n" + exception3.Message, "Save Failed");
            }
        }

        [CodeDescription("Save Selected Request Bodies to Files feature.")]
        public void actSaveSessionRequestBody()
        {
            this.dlgSaveBinary.Title = "Save request bodies to...";
            foreach (Session session in this.GetSelectedSessions())
            {
                if ((session.requestBodyBytes != null) && (0L != session.requestBodyBytes.LongLength))
                {
                    if (DialogResult.OK != this.dlgSaveBinary.ShowDialog(this))
                    {
                        break;
                    }
                    FileStream stream = new FileStream(this.dlgSaveBinary.FileName, FileMode.Create, FileAccess.Write);
                    stream.Write(session.requestBodyBytes, 0, session.requestBodyBytes.Length);
                    stream.Close();
                }
                else
                {
                    FiddlerApplication.DoNotifyUser("There is no request body to save.", "Error");
                }
            }
        }

        [CodeDescription("Save Selected Response Bodies to Files feature.")]
        public void actSaveSessionResponseBody()
        {
            this.dlgSaveBinary.Title = "Save response bodies to...";
            foreach (Session session in this.GetSelectedSessions())
            {
                if ((session.responseBodyBytes != null) && (0L != session.responseBodyBytes.LongLength))
                {
                    this.dlgSaveBinary.FileName = session.SuggestedFilename;
                    if (DialogResult.OK != this.dlgSaveBinary.ShowDialog(this))
                    {
                        break;
                    }
                    session.SaveResponseBody(this.dlgSaveBinary.FileName);
                }
                else
                {
                    FiddlerApplication.DoNotifyUser("There is no response body to save for session #" + session.id.ToString() + ".", "No response body");
                }
            }
        }

        [CodeDescription("Launch the Save Selected Sessions to Single File feature.")]
        public void actSaveSessions()
        {
            if (this.lvSessions.SelectedCount >= 1)
            {
                this.dlgSaveBinary.Title = "Save sessions as one text file";
                this.dlgSaveBinary.FileName = this.GetFirstSelectedSession().id.ToString() + "_Full.txt";
                if (DialogResult.OK == this.dlgSaveBinary.ShowDialog(this))
                {
                    this.actSaveSessions(this.dlgSaveBinary.FileName, false);
                }
            }
        }

        [CodeDescription("Save Selected Sessions to Single File named sFilename.")]
        public void actSaveSessions(string sFilename, bool bHeadersOnly)
        {
            string s = "\r\n\r\n------------------------------------------------------------------\r\n\r\n";
            FileStream oFS = new FileStream(sFilename, FileMode.Create, FileAccess.Write);
            Session[] selectedSessions = this.GetSelectedSessions();
            foreach (Session session in selectedSessions)
            {
                session.WriteToStream(oFS, bHeadersOnly);
                if (selectedSessions.Length > 1)
                {
                    oFS.Write(Encoding.ASCII.GetBytes(s), 0, s.Length);
                }
            }
            oFS.Close();
        }

        [CodeDescription("Launch the Save Selected Sessions to ZipArchive feature.")]
        public void actSaveSessionsToZip()
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length < 1)
            {
                FiddlerApplication.DoNotifyUser("Please select sessions in the Session List first", "Cannot Save SAZ");
            }
            else
            {
                this.actSaveSessionArchive(selectedSessions);
            }
        }

        [CodeDescription("Save Selected sessions to ZipArchive named by sFilename.")]
        public void actSaveSessionsToZip(string sFilename)
        {
            this.actSaveSessionsToZip(sFilename, null);
        }

        [CodeDescription("Save Selected sessions to ZipArchive named by sFilename, protected by password sPassword.")]
        public void actSaveSessionsToZip(string sFilename, string sPassword)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length < 1)
            {
                FiddlerApplication.DoNotifyUser("Please select sessions in the Session List first", "Cannot Save SAZ");
            }
            else
            {
                this.actSaveSessionArchive(sFilename, sPassword, selectedSessions);
            }
        }

        [CodeDescription("Select all sessions in the Web Sessions List")]
        public void actSelectAll()
        {
            this.lvSessions.BeginUpdate();
            FiddlerApplication.SuppressReportUpdates = true;
            foreach (ListViewItem item in this.lvSessions.Items)
            {
                item.Selected = true;
            }
            FiddlerApplication.SuppressReportUpdates = false;
            this.lvSessions.EndUpdate();
        }

        private static string actSelectImportExportFormat(bool bIsImport, string[] arrFormats)
        {
            string sValue = null;
            Form frmPickType = new Form();
            Utilities.AdjustFontSize(frmPickType, CONFIG.flFontSize);
            frmPickType.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            frmPickType.Size = new Size(400, 0xa5);
            frmPickType.MinimumSize = new Size(0x109, 150);
            frmPickType.Text = bIsImport ? "Select Import Format" : "Select Export Format";
            ComboBox oCbx = new ComboBox();
            Utilities.AdjustFontSize(oCbx, CONFIG.flFontSize);
            oCbx.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            oCbx.DropDownStyle = ComboBoxStyle.DropDownList;
            oCbx.Items.AddRange(arrFormats);
            oCbx.Width = 0x177;
            frmPickType.Controls.Add(oCbx);
            oCbx.Location = new Point(5, 5);
            TextBox txtDescription = new TextBox();
            frmPickType.Controls.Add(txtDescription);
            txtDescription.BorderStyle = BorderStyle.None;
            txtDescription.ReadOnly = true;
            txtDescription.BackColor = frmPickType.BackColor;
            txtDescription.WordWrap = true;
            txtDescription.Multiline = true;
            txtDescription.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            txtDescription.Location = new Point(5, 0x23);
            txtDescription.Size = new Size(0x177, 50);
            Button button = new Button();
            button.AutoSize = true;
            button.Text = "&Next";
            frmPickType.Controls.Add(button);
            button.Left = (frmPickType.ClientSize.Width - button.Width) - 10;
            button.Top = (frmPickType.ClientSize.Height - button.Height) - 10;
            button.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            frmPickType.AcceptButton = button;
            button.Click += delegate(object s2, EventArgs ea2)
            {
                frmPickType.DialogResult = DialogResult.OK;
            };
            oCbx.SelectedIndexChanged += delegate(object sender, EventArgs oEA)
            {
                TranscoderTuple tuple;
                if (bIsImport)
                {
                    if (FiddlerApplication.oTranscoders.m_Importers.TryGetValue(oCbx.SelectedItem.ToString(), out tuple))
                    {
                        txtDescription.Text = tuple.sFormatDescription;
                    }
                }
                else if (FiddlerApplication.oTranscoders.m_Exporters.TryGetValue(oCbx.SelectedItem.ToString(), out tuple))
                {
                    txtDescription.Text = tuple.sFormatDescription;
                }
            };
            string stringPref = FiddlerApplication.Prefs.GetStringPref(bIsImport ? "fiddler.importexport.LastImportFormat" : "fiddler.importexport.LastExportFormat", string.Empty);
            int num = 0;
            if (!string.IsNullOrEmpty(stringPref))
            {
                num = oCbx.FindStringExact(stringPref);
                if (num < 0)
                {
                    num = 0;
                }
            }
            oCbx.SelectedIndex = num;
            Button button2 = new Button();
            button2.AutoSize = true;
            button2.Text = "&Cancel";
            frmPickType.Controls.Add(button2);
            button2.Left = 10;
            button2.Top = (frmPickType.ClientSize.Height - button2.Height) - 10;
            button2.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            frmPickType.KeyPreview = true;
            frmPickType.KeyUp += delegate(object s, KeyEventArgs k)
            {
                if (k.KeyCode == Keys.Escape)
                {
                    k.Handled = true;
                    k.SuppressKeyPress = true;
                    frmPickType.DialogResult = DialogResult.Cancel;
                }
            };
            button2.Click += delegate(object s2, EventArgs ea2)
            {
                frmPickType.DialogResult = DialogResult.Cancel;
            };
            frmPickType.StartPosition = FormStartPosition.CenterParent;
            if (DialogResult.OK == frmPickType.ShowDialog(FiddlerApplication.UI))
            {
                sValue = oCbx.SelectedItem.ToString();
                FiddlerApplication.Prefs.SetStringPref(bIsImport ? "fiddler.importexport.LastImportFormat" : "fiddler.importexport.LastExportFormat", sValue);
            }
            frmPickType.Dispose();
            return sValue;
        }

        private void actSelectMarkedSessions(string sColor)
        {
            this.actSelectSessionsMatchingCriteria(delegate(Session oS)
            {
                return oS.oFlags.ContainsKey("UI-BOLD") && (oS.oFlags["UI-COLOR"] == sColor);
            });
            this.SetStatusText(string.Format("Selected sessions marked in {0}", sColor));
        }

        [CodeDescription("Select Sessions for which the provided matching function returns boolean True")]
        public void actSelectSessionsMatchingCriteria(doesSessionMatchCriteriaDelegate oDel)
        {
            this.actSelectSessionsMatchingCriteria(0, oDel);
        }

        [CodeDescription("Select up to iSelAtMost Sessions for which the provided matching function returns boolean True")]
        public void actSelectSessionsMatchingCriteria(int iSelAtMost, doesSessionMatchCriteriaDelegate oDel)
        {
            int num = 0;
            FiddlerApplication.SuppressReportUpdates = true;
            this.lvSessions.BeginUpdate();
            this.lvSessions.SelectedItems.Clear();
            foreach (ListViewItem item in this.lvSessions.Items)
            {
                Session tag = (Session)item.Tag;
                if ((tag != null) && oDel(tag))
                {
                    item.Selected = true;
                    if ((iSelAtMost > 0) && (++num >= iSelAtMost))
                    {
                        break;
                    }
                }
            }
            this.sbpInfo.Text = string.Empty;
            this.lvSessions.EndUpdate();
            FiddlerApplication.SuppressReportUpdates = false;
            this.actUpdateInspector(true, true);
        }

        [CodeDescription("Select Sessions with Request[sHeader] value of containing sPartialValue")]
        public void actSelectSessionsWithRequestHeaderValue(string sHeader, string sPartialValue)
        {
            this.actSelectSessionsMatchingCriteria(delegate(Session oS)
            {
                return ((oS.oRequest != null) && (oS.oRequest.headers != null)) && oS.oRequest.headers.ExistsAndContains(sHeader, sPartialValue);
            });
        }

        [CodeDescription("Select Sessions with responseCode == iStatus")]
        public void actSelectSessionsWithResponseCode(uint iStatus)
        {
            this.actSelectSessionsMatchingCriteria(delegate(Session oS)
            {
                return oS.responseCode == iStatus;
            });
        }

        [CodeDescription("Select Sessions with Response[sHeader] containing sPartialValue")]
        public void actSelectSessionsWithResponseHeaderValue(string sHeader, string sPartialValue)
        {
            this.actSelectSessionsMatchingCriteria(delegate(Session oS)
            {
                return ((oS.oResponse != null) && (oS.oResponse.headers != null)) && oS.oResponse.headers.ExistsAndContains(sHeader, sPartialValue);
            });
        }

        [CodeDescription("Select Sessions with a response body of at (least/most) iSize bytes")]
        public void actSelectSessionsWithResponseSize(bool bGreater, long iSize)
        {
            this.actSelectSessionsMatchingCriteria(delegate(Session oS)
            {
                if ((oS.responseBodyBytes == null) || ((!bGreater || (iSize >= oS.responseBodyBytes.LongLength)) && (bGreater || (iSize <= oS.responseBodyBytes.LongLength))))
                {
                    return false;
                }
                return true;
            });
        }

        public void actSessionCopy()
        {
            this.CopySessions(false);
        }

        public void actSessionCopyHeaders()
        {
            this.CopySessions(true);
        }

        [CodeDescription("Copies the terse summary of currently selected sessions to the clipboard.")]
        public void actSessionCopyHeadlines()
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                StringBuilder builder = new StringBuilder(0x200);
                foreach (Session session in selectedSessions)
                {
                    if ((session.oRequest != null) && (session.oRequest.headers != null))
                    {
                        builder.AppendFormat("{0} {1}\r\n", session.oRequest.headers.HTTPMethod, session.fullUrl);
                    }
                    if ((session.oResponse != null) && (session.oResponse.headers != null))
                    {
                        if (Utilities.IsRedirectStatus(session.responseCode))
                        {
                            builder.AppendFormat("{0} to {1}\r\n", session.oResponse.headers.HTTPResponseStatus, session.oResponse["Location"]);
                        }
                        else
                        {
                            builder.AppendFormat("{0} ({1})\r\n", session.oResponse.headers.HTTPResponseStatus, session.oResponse.MIMEType);
                        }
                    }
                    else
                    {
                        builder.Append("No response\r\n");
                    }
                    if (selectedSessions.Length > 1)
                    {
                        builder.Append("\r\n");
                    }
                }
                Utilities.CopyToClipboard(builder.ToString());
            }
        }

        [CodeDescription("Copies summary of the currently selected sessions to the clipboard.")]
        public void actSessionCopySummary()
        {
            ListView.SelectedListViewItemCollection selectedItems = this.lvSessions.SelectedItems;
            if (selectedItems.Count >= 1)
            {
                StringBuilder data = new StringBuilder(0x200);
                StringBuilder builder2 = new StringBuilder(0x200);
                builder2.Append("<table><tr>");
                foreach (ColumnHeader header in this.lvSessions.Columns)
                {
                    data.Append(header.Text);
                    data.Append("\t");
                    builder2.AppendFormat("<th>{0}</th>", Utilities.HtmlEncode(header.Text));
                }
                data.Append("\r\n");
                builder2.Append("</tr><tr>");
                foreach (ListViewItem item in selectedItems)
                {
                    foreach (ListViewItem.ListViewSubItem item2 in item.SubItems)
                    {
                        data.Append(item2.Text);
                        data.Append("\t");
                        builder2.AppendFormat("<td>{0}</td>", Utilities.HtmlEncode(item2.Text));
                    }
                    data.Append("\r\n");
                    builder2.Append("</tr>");
                }
                DataObject oData = new DataObject("HTML Format", Utilities.StringToCF_HTML(builder2.ToString()));
                oData.SetData(DataFormats.Text, data);
                Utilities.CopyToClipboard(oData);
            }
        }

        [CodeDescription("Copies the URLs of currently selected sessions to the clipboard.")]
        public void actSessionCopyURL()
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                if (1 == selectedSessions.Length)
                {
                    Utilities.CopyToClipboard(selectedSessions[0].fullUrl);
                }
                StringBuilder builder = new StringBuilder(0x200);
                foreach (Session session in selectedSessions)
                {
                    if ((session.oRequest != null) && (session.oRequest.headers != null))
                    {
                        builder.AppendFormat("{0}\r\n", session.fullUrl);
                    }
                }
                Utilities.CopyToClipboard(builder.ToString());
            }
        }

        public void actSessionMark(System.Drawing.Color c)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length > 0)
            {
                this.actSessionMark(c, selectedSessions);
            }
        }

        public void actSessionMark(System.Drawing.Color c, Session[] oSessions)
        {
            this.lvSessions.BeginUpdate();
            foreach (Session session in oSessions)
            {
                if (session.ViewItem != null)
                {
                    ListViewItem viewItem = session.ViewItem;
                    if (c != System.Drawing.Color.Empty)
                    {
                        viewItem.Font = new Font(viewItem.Font, FontStyle.Bold);
                        if ((session.oFlags["ui-bold"] != "user-marked") && (viewItem.ForeColor != System.Drawing.Color.Black))
                        {
                            session.oFlags["ui-oldcolor"] = Utilities.GetStringFromColor(viewItem.ForeColor);
                        }
                        session.oFlags["ui-bold"] = "user-marked";
                        session.oFlags["ui-color"] = Utilities.GetStringFromColor(c);
                        viewItem.ForeColor = c;
                    }
                    else
                    {
                        viewItem.Font = new Font(viewItem.Font, FontStyle.Regular);
                        viewItem.ForeColor = System.Drawing.Color.Black;
                        viewItem.BackColor = this.lvSessions.BackColor;
                        string sColor = session.oFlags["ui-oldcolor"];
                        if (sColor != null)
                        {
                            viewItem.ForeColor = Utilities.GetColorFromString(sColor);
                        }
                        session.oFlags.Remove("ui-bold");
                        session.oFlags.Remove("ui-oldcolor");
                        session.oFlags.Remove("ui-color");
                    }
                }
            }
            this.lvSessions.EndUpdate();
        }

        [CodeDescription("Set the font size for (some) Fiddler UI elements.")]
        public void actSetFontSize(float flFontSize)
        {
            try
            {
                flFontSize = Math.Min(flFontSize, 24f);
                flFontSize = Math.Max(flFontSize, 4f);
                base.SuspendLayout();
                FiddlerApplication.Reporter.FontSize = flFontSize;
                this.lvSessions.Font = new Font(this.lvSessions.Font.FontFamily, flFontSize);
                this.sbStatus.Font = new Font(this.sbStatus.Font.FontFamily, flFontSize);
                this.txtExec.Font = new Font(this.txtExec.Font.FontFamily, flFontSize);
                if (FiddlerApplication.oInspectors != null)
                {
                    FiddlerApplication.oInspectors.AnnounceFontSizeChange(flFontSize);
                }
                CONFIG.flFontSize = flFontSize;
                FiddlerApplication.Prefs.SetStringPref("fiddler.ui.font.size", flFontSize.ToString("##.##"));
            }
            finally
            {
                base.ResumeLayout();
            }
        }

        [CodeDescription("Show the Fiddler Options dialog")]
        public void actShowOptions()
        {
            this.actShowOptions(null);
        }

        [CodeDescription("Show the Fiddler Options dialog, activating a particular tab")]
        public void actShowOptions(string sTabName)
        {
            frmOptions options = new frmOptions();
            if (!string.IsNullOrEmpty(sTabName))
            {
                options.SelectTab(sTabName);
            }
            options.ShowDialog(this);
            options.Dispose();
        }

        public void actShowTextWizard(string sDefaultInput)
        {
            frmTextWizard wizard = new frmTextWizard(sDefaultInput);
            wizard.Left = base.Left + 100;
            wizard.Top = base.Top + 100;
            wizard.Show(this);
        }

        internal bool actTearoffInspectors()
        {
            if (this._frmFloatingInspectors != null)
            {
                return false;
            }
            base.SuspendLayout();
            this.btnSquish.Visible = false;
            this.miViewSquish.Enabled = false;
            this.miViewDefault.Enabled = this.miViewWide.Enabled = this.miViewStacked.Enabled = false;
            this._frmFloatingInspectors = new Form();
            this._frmFloatingInspectors.FormBorderStyle = FormBorderStyle.Sizable;
            this._frmFloatingInspectors.Width = 500;
            this._frmFloatingInspectors.Height = base.Height;
            this._frmFloatingInspectors.StartPosition = FormStartPosition.Manual;
            this._frmFloatingInspectors.Left = (base.Left + base.Width) - 500;
            this._frmFloatingInspectors.Top = base.Top + 0x19;
            this._frmFloatingInspectors.Text = "Fiddler - Details View";
            this._frmFloatingInspectors.Controls.Add(this.tabsViews);
            this._frmFloatingInspectors.Icon = base.Icon;
            this._frmFloatingInspectors.FormClosing += new FormClosingEventHandler(this.frmFloatingInspectors_FormClosing);
            this.splitterMain.Visible = false;
            this.pnlInspector.Dock = DockStyle.Right;
            this.pnlInspector.Width = 0;
            this.pnlSessions.Dock = DockStyle.Fill;
            base.ResumeLayout();
            this._frmFloatingInspectors.Show(this);
            return true;
        }

        public void actToggleCapture()
        {
            if (FiddlerApplication.oProxy.IsAttached)
            {
                this.actDetachProxy();
            }
            else
            {
                this.actAttachProxy();
            }
        }

        private void actToggleSessionUnlock()
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                if (!firstSelectedSession.oFlags.ContainsKey("x-Unlocked"))
                {
                    if (firstSelectedSession.state < SessionStates.Done)
                    {
                        return;
                    }
                    firstSelectedSession.oFlags["x-Unlocked"] = "User-Request";
                    if (firstSelectedSession.ViewItem != null)
                    {
                        firstSelectedSession.ViewItem.ImageIndex = 0x24;
                    }
                }
                else
                {
                    this.actUpdateRequest(firstSelectedSession);
                    this.actUpdateResponse(firstSelectedSession);
                    firstSelectedSession.oFlags.Remove("x-Unlocked");
                    this._RefreshSessionListViewItem(firstSelectedSession, firstSelectedSession.ViewItem);
                }
                this.actUpdateInspector(true, true);
            }
        }

        public void actToggleSquish()
        {
            if (this.pnlSessions.Width == 0x34)
            {
                this.miViewSquish.Checked = false;
                this.btnSquish.Text = "<<";
                this.pnlSessions.Width = Math.Max(this._iUnsquishedSessionListWidth, 360);
            }
            else
            {
                this.miViewSquish.Checked = true;
                this.btnSquish.Text = ">>";
                this._iUnsquishedSessionListWidth = this.pnlSessions.Width;
                this.pnlSessions.Width = 0x34;
            }
        }

        public void actToggleStackedLayout(bool bStacked)
        {
            this.actChangeToLayout(bStacked ? 1 : 0);
        }

        [CodeDescription("Reissue the selected requests unconditionally. If SHIFT key is held down, user will be prompted for repeat count")]
        public void actUnconditionallyReissueSelected()
        {
            int result = 1;
            if (Keys.Shift == (Control.ModifierKeys & Keys.Shift))
            {
                string s = frmPrompt.GetUserString("Repeat Count", "Reissue this Request (Unconditionally) how many times?", "5", true);
                if (s == null)
                {
                    return;
                }
                if (!int.TryParse(s, out result))
                {
                    return;
                }
            }
            Session[] selectedSessions = this.GetSelectedSessions();
            StringDictionary oNewFlags = new StringDictionary();
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.reissue.autoauth", false))
            {
                oNewFlags.Add("x-AutoAuth", "(default)");
            }
            if (FiddlerApplication.Prefs.GetInt32Pref("fiddler.reissue.autoredircount", 0) > 0)
            {
                oNewFlags.Add("x-Builder-MaxRedir", FiddlerApplication.Prefs.GetInt32Pref("fiddler.reissue.autoredircount", 0).ToString());
            }
            for (int i = 0; i < result; i++)
            {
                for (int j = 0; j < selectedSessions.Length; j++)
                {
                    if ((selectedSessions[j].oRequest != null) && (selectedSessions[j].oRequest.headers != null))
                    {
                        HTTPRequestHeaders oHeaders = (HTTPRequestHeaders)selectedSessions[j].oRequest.headers.Clone();
                        oHeaders.Remove("Range");
                        oHeaders.Remove("If-Modified-Since");
                        oHeaders.Remove("If-Unmodified-Since");
                        oHeaders.Remove("Unless-Modified-Since");
                        oHeaders.Remove("If-Range");
                        oHeaders.Remove("If-Match");
                        oHeaders.Remove("If-None-Match");
                        FiddlerApplication.oProxy.SendRequest(oHeaders, selectedSessions[j].requestBodyBytes, oNewFlags);
                    }
                }
            }
        }

        private void actUpdateBothInspectorsNow()
        {
            this.actUpdateInspector(true, true, true);
        }

        public void actUpdateInspector(bool bRequest, bool bResponse)
        {
            this.actUpdateInspector(bRequest, bResponse, false);
        }

        private void actUpdateInspector(bool bRequest, bool bResponse, bool bImmediate)
        {
            SimpleEventHandler workFunction = null;
            if (!FiddlerApplication.isClosing && (this.tabsViews.SelectedTab == this.pageInspector))
            {
                if (!bImmediate && (this.lvSessions.SelectedCount != 1))
                {
                    if (workFunction == null)
                    {
                        workFunction = delegate
                        {
                            FiddlerApplication.UIInvokeAsync(new MethodInvoker(this.actUpdateBothInspectorsNow), null);
                        };
                    }
                    ScheduledTasks.ScheduleWork("UpdateInspectors", 100, workFunction);
                }
                else
                {
                    ScheduledTasks.CancelWork("UpdateInspectors");
                    if (this.lvSessions.SelectedCount != 1)
                    {
                        if (!FiddlerApplication.isClosing)
                        {
                            try
                            {
                                this.pageInspector.SuspendLayout();
                                this.pnlSessionControls.Visible = this.pnlInfoBar.Visible = this.pnlInfoTip.Visible = this.pnlInfoTipRequest.Visible = this.tabsRequest.Visible = this.splitterInspector.Visible = this.tabsResponse.Visible = false;
                                if (this.lblInspectOne == null)
                                {
                                    this.lblInspectOne = new Label();
                                    this.lblInspectOne.TextAlign = ContentAlignment.MiddleCenter;
                                    this.lblInspectOne.Font = new Font(this.lblInspectOne.Font, FontStyle.Italic);
                                    this.lblInspectOne.Text = "Please select a single Web Session to inspect";
                                    this.lblInspectOne.Parent = this.pageInspector;
                                    this.lblInspectOne.ForeColor = System.Drawing.Color.FromKnownColor(KnownColor.ControlDarkDark);
                                    this.lblInspectOne.Dock = DockStyle.Fill;
                                }
                                else
                                {
                                    this.lblInspectOne.Visible = true;
                                }
                            }
                            finally
                            {
                                this.pageInspector.ResumeLayout();
                            }
                        }
                    }
                    else
                    {
                        if (this.lblInspectOne != null)
                        {
                            this.lblInspectOne.Visible = false;
                        }
                        this.pageInspector.SuspendLayout();
                        this.tabsRequest.Visible = this.splitterInspector.Visible = this.tabsResponse.Visible = true;
                        Session firstSelectedSession = this.GetFirstSelectedSession();
                        this.pnlInfoBar.Visible = (((firstSelectedSession != null) && !CONFIG.bMITM_HTTPS) && firstSelectedSession.HTTPMethodIs("CONNECT")) && !firstSelectedSession.isFlagSet(SessionFlags.LoadedFromSAZ);
                        this.btnTamperSendServer.Enabled = (firstSelectedSession != null) && (firstSelectedSession.state == SessionStates.HandTamperRequest);
                        this.btnTamperSendClient.Enabled = (firstSelectedSession != null) && ((firstSelectedSession.state == SessionStates.HandTamperRequest) || (firstSelectedSession.state == SessionStates.HandTamperResponse));
                        this.pnlSessionControls.Visible = this.btnTamperSendServer.Enabled || this.btnTamperSendClient.Enabled;
                        if (this.cbxLoadFrom.Items.Count > 0)
                        {
                            this.cbxLoadFrom.SelectedIndex = 0;
                        }
                        if (((firstSelectedSession != null) && (firstSelectedSession.oRequest != null)) && (firstSelectedSession.oRequest.headers != null))
                        {
                            this.pnlInfoTipRequest.Visible = ((firstSelectedSession.requestBodyBytes != null) && (firstSelectedSession.requestBodyBytes.Length > 0)) && (firstSelectedSession.oRequest.headers.Exists("Transfer-Encoding") || firstSelectedSession.oRequest.headers.Exists("Content-Encoding"));
                        }
                        else
                        {
                            this.pnlInfoTip.Visible = false;
                        }
                        if (((firstSelectedSession != null) && (firstSelectedSession.oResponse != null)) && (firstSelectedSession.oResponse.headers != null))
                        {
                            this.pnlInfoTip.Visible = ((firstSelectedSession.responseBodyBytes != null) && (firstSelectedSession.responseBodyBytes.Length > 0)) && (firstSelectedSession.oResponse.headers.Exists("Transfer-Encoding") || firstSelectedSession.oResponse.headers.Exists("Content-Encoding"));
                        }
                        else
                        {
                            this.pnlInfoTip.Visible = false;
                        }
                        this.pageInspector.ResumeLayout();
                        if (bRequest)
                        {
                            IRequestInspector2 activeRequestInspector = this.GetActiveRequestInspector();
                            if (activeRequestInspector != null)
                            {
                                try
                                {
                                    if (firstSelectedSession == null)
                                    {
                                        activeRequestInspector.Clear();
                                    }
                                    else
                                    {
                                        (activeRequestInspector as Inspector2).AssignSession(firstSelectedSession);
                                    }
                                }
                                catch (Exception exception)
                                {
                                    FiddlerApplication.LogAddonException(exception, "Request Inspector Failed");
                                }
                            }
                        }
                        if (bResponse)
                        {
                            IResponseInspector2 activeResponseInspector = this.GetActiveResponseInspector();
                            if (activeResponseInspector != null)
                            {
                                try
                                {
                                    if (firstSelectedSession == null)
                                    {
                                        activeResponseInspector.Clear();
                                    }
                                    else
                                    {
                                        (activeResponseInspector as Inspector2).AssignSession(firstSelectedSession);
                                    }
                                }
                                catch (Exception exception2)
                                {
                                    FiddlerApplication.LogAddonException(exception2, "Response Inspector Failed");
                                }
                            }
                        }
                    }
                }
            }
        }

        public void actUpdateReport()
        {
            FiddlerApplication.OnCalculateReport(this.GetSelectedSessions());
        }

        private void actUpdateRequest(Session oSession)
        {
            IRequestInspector2 activeRequestInspector = this.GetActiveRequestInspector();
            if ((activeRequestInspector != null) && (activeRequestInspector as Inspector2).CommitAnyChanges(oSession))
            {
                this.sbpInfo.Text = "Auto-saved changes to request from " + activeRequestInspector.GetType().ToString() + " at " + DateTime.Now.TimeOfDay.ToString();
            }
        }

        private void actUpdateResponse(Session oSession)
        {
            IResponseInspector2 activeResponseInspector = this.GetActiveResponseInspector();
            if ((activeResponseInspector != null) && (activeResponseInspector as Inspector2).CommitAnyChanges(oSession))
            {
                this.sbpInfo.Text = "Auto-saved changes to response from " + activeResponseInspector.GetType().ToString() + " at " + DateTime.Now.TimeOfDay.ToString();
            }
        }

        public void actValidateRequest(object sender, CancelEventArgs e)
        {
            if (!FiddlerApplication.isClosing && (this.lvSessions.SelectedCount >= 1))
            {
                Session firstSelectedSession = this.GetFirstSelectedSession();
                if (firstSelectedSession != null)
                {
                    this.actUpdateRequest(firstSelectedSession);
                }
            }
        }

        public void actValidateResponse(object sender, CancelEventArgs e)
        {
            if (!FiddlerApplication.isClosing && (this.lvSessions.SelectedCount >= 1))
            {
                Session firstSelectedSession = this.GetFirstSelectedSession();
                if (firstSelectedSession != null)
                {
                    this.actUpdateResponse(firstSelectedSession);
                }
            }
        }

        [CodeDescription("Display session properties dialog of the (1) currently selected session.")]
        public void actViewSessionProperties()
        {
            if (this.lvSessions.SelectedCount == 1)
            {
                Session firstSelectedSession = this.GetFirstSelectedSession();
                if (firstSelectedSession != null)
                {
                    SessionProperties properties = new SessionProperties(firstSelectedSession);
                    properties.Left = base.Left + 250;
                    properties.Top = base.Top + 60;
                    properties.Show(this);
                }
            }
        }

        public Session AddReportedSession(byte[] arrRequest, byte[] arrResponse, Stream strmMetadata)
        {
            return this.AddReportedSession(arrRequest, arrResponse, strmMetadata, SessionFlags.None);
        }

        internal Session AddReportedSession(byte[] arrRequest, byte[] arrResponse, Stream strmMetadata, SessionFlags oAdditionalFlags)
        {
            Session oSession = new Session(arrRequest, arrResponse);
            if (strmMetadata != null)
            {
                oSession.LoadMetadata(strmMetadata);
            }
            oSession.BitFlags |= oAdditionalFlags;
            ListViewItem oLVI = new ListViewItem(oSession.id.ToString(), 0);
            oLVI.Tag = oSession;
            oSession.ViewItem = oLVI;
            oLVI.SubItems.AddRange(new string[] { " - ", oSession.oRequest.headers.UriScheme.ToUpper(), oSession.host, oSession.PathAndQuery, "-1", string.Empty, string.Empty, oSession["SESSION", "x-ProcessInfo"], oSession["SESSION", "ui-comments"], oSession["SESSION", "ui-customcolumn"] });
            oLVI.SubItems.AddRange(this.lvSessions._emptyBoundColumns);
            SessionListView.FillBoundColumns(oSession, oLVI);
            this.lvSessions.QueueItem(oLVI);
            this.finishSession(oSession);
            return oSession;
        }

        public void addSession(Session oSession)
        {
            if ((oSession.ViewItem == null) && !oSession.ShouldBeHidden())
            {
                this._coreAddSession(oSession, false);
            }
        }

        private void btnDecodeRequest_Click(object sender, EventArgs e)
        {
            this.actValidateRequest(sender, null);
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                if ((firstSelectedSession.state > SessionStates.ReadingRequest) && (firstSelectedSession.requestBodyBytes != null))
                {
                    firstSelectedSession.utilDecodeRequest();
                    this.actUpdateInspector(true, false);
                }
                else
                {
                    FiddlerApplication.DoNotifyUser("Full request data is not available for decoding.", "Decoding skipped", MessageBoxIcon.Asterisk);
                }
            }
        }

        private void btnDecodeResponse_Click(object sender, EventArgs e)
        {
            this.actValidateResponse(sender, null);
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                if ((firstSelectedSession.state > SessionStates.ReadingResponse) && (firstSelectedSession.responseBodyBytes != null))
                {
                    firstSelectedSession.utilDecodeResponse();
                    if ((Control.ModifierKeys != Keys.None) && (FiddlerApplication.oInspectors != null))
                    {
                        DictionaryEntry entry = FiddlerApplication.oInspectors.FindBestResponseInspector(firstSelectedSession);
                        if (entry.Key != null)
                        {
                            this.tabsResponse.SelectedTab = (TabPage)entry.Key;
                        }
                    }
                    this.actUpdateInspector(false, true);
                }
                else
                {
                    FiddlerApplication.DoNotifyUser("Full response data is not available for decoding.", "Decoding skipped", MessageBoxIcon.Asterisk);
                }
            }
        }

        private void btnPromptHTTPS_Click(object sender, EventArgs e)
        {
            this.actShowOptions("HTTPS");
        }

        private void btnSquish_Click(object sender, EventArgs e)
        {
            this.actToggleSquish();
        }

        private void btnTamperSend_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                firstSelectedSession.oFlags["x-breakresponse"] = "USERREQUEST";
                firstSelectedSession.bBufferResponse = true;
                this.ResumeBreakpointedSession(firstSelectedSession);
            }
        }

        private void btnTamperSendClient_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                firstSelectedSession.oFlags.Remove("x-breakresponse");
                this.ResumeBreakpointedSession(firstSelectedSession);
            }
        }

        private void btnWarnDetached_Click(object sender, EventArgs e)
        {
            this.actAttachProxy(true);
        }

        private void cbxLoadFrom_SelectionChangeCommitted(object sender, EventArgs e)
        {
            string text;
            Session firstSelectedSession;
            if (this.cbxLoadFrom.SelectedIndex >= 1)
            {
                text = this.cbxLoadFrom.Text;
                if (this.lvSessions.SelectedCount != 1)
                {
                    return;
                }
                firstSelectedSession = this.GetFirstSelectedSession();
                if (firstSelectedSession == null)
                {
                    return;
                }
                if ((firstSelectedSession.state != SessionStates.HandTamperRequest) && (firstSelectedSession.state != SessionStates.HandTamperResponse))
                {
                    return;
                }
                if (!(text == "Find a file..."))
                {
                    goto Label_00BF;
                }
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.DefaultExt = "dat";
                dialog.Title = "Choose response file";
                dialog.Filter = "All Files (*.*)|*.*|Response Files (*.dat)|*.dat";
                if (DialogResult.OK == dialog.ShowDialog(this))
                {
                    this.cbxLoadFrom.Items.Insert(1, dialog.FileName);
                    this.cbxLoadFrom.SelectedIndex = 1;
                    text = dialog.FileName;
                    dialog.Dispose();
                    goto Label_00BF;
                }
                dialog.Dispose();
            }
            return;
        Label_00BF:
            if (firstSelectedSession.state != SessionStates.HandTamperResponse)
            {
                firstSelectedSession.state = SessionStates.HandTamperResponse;
            }
            firstSelectedSession.oResponse = new ServerChatter(firstSelectedSession, "HTTP/1.1 200 OK\r\nServer: Fiddler\r\n\r\n");
            firstSelectedSession.LoadResponseFromFile(text);
            this.actUpdateInspector(false, true);
        }

        [CodeDescription("Copies currently selected sessions to the clipboard.")]
        public void CopySessions(bool HeadersOnly)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                StringBuilder data = new StringBuilder(0x200);
                StringBuilder builder2 = new StringBuilder(0x200);
                foreach (Session session in selectedSessions)
                {
                    builder2.Append(session.ToHTMLFragment(HeadersOnly));
                    data.Append(session.ToString(HeadersOnly));
                    if (selectedSessions.Length > 1)
                    {
                        builder2.Append("<HR>");
                        data.Append("\r\n------------------------------------------------------------------\r\n");
                    }
                }
                DataObject oData = new DataObject("HTML Format", Utilities.StringToCF_HTML(builder2.ToString()));
                oData.SetData(DataFormats.Text, data);
                Utilities.CopyToClipboard(oData);
            }
        }

        internal bool CreateSessionsForFile(string sFilename, string sRelativeTo)
        {
            if ((sFilename == null) || !System.IO.File.Exists(sFilename))
            {
                return false;
            }
            try
            {
                if (sFilename.EndsWith(".saz", StringComparison.OrdinalIgnoreCase))
                {
                    return this.actLoadSessionArchive(sFilename);
                }
                string str = null;
                if (string.IsNullOrEmpty(sRelativeTo))
                {
                    str = string.Format("/{0}", Path.GetFileName(sFilename));
                }
                else
                {
                    str = sFilename.Substring(sRelativeTo.Length).Replace('\\', '/');
                }
                str = Utilities.UrlPathEncode(str);
                HTTPRequestHeaders headers = new HTTPRequestHeaders();
                headers.HTTPMethod = "GET";
                headers.Add("Host", "localhost");
                headers.RequestPath = str;
                byte[] arrRequest = headers.ToByteArray(true, true, false);
                byte[] bytes = Encoding.UTF8.GetBytes(string.Format("HTTP/1.1 200 OK\r\nContent-Type: {0}\r\nCache-Control: max-age=0, must-revalidate\r\nConnection: close\r\n\r\n", Utilities.ContentTypeForFileExtension(Path.GetExtension(sFilename))));
                byte[] buffer = System.IO.File.ReadAllBytes(sFilename);
                MemoryStream stream = new MemoryStream();
                stream.Write(bytes, 0, bytes.Length);
                stream.Write(buffer, 0, buffer.Length);
                Session oSession = new Session(arrRequest, stream.ToArray(), SessionFlags.ServedFromCache | SessionFlags.ImportedFromOtherTool | SessionFlags.ResponseGeneratedByFiddler | SessionFlags.RequestGeneratedByFiddler);
                if (Clipboard.ContainsData("UniformResourceLocatorW"))
                {
                    try
                    {
                        MemoryStream data = (MemoryStream)Clipboard.GetData("UniformResourceLocatorW");
                        oSession["ui-comments"] = Encoding.Unicode.GetString(data.ToArray());
                        data.Dispose();
                    }
                    catch (Exception exception)
                    {
                        oSession["ui-comments"] = exception.Message;
                    }
                }
                else
                {
                    oSession["ui-comments"] = sFilename;
                }
                oSession.state = SessionStates.Done;
                this.finishSession(oSession);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        internal void CreateSessionsForFolder(string sFolderName)
        {
            DirectoryInfo info = new DirectoryInfo(sFolderName);
            foreach (FileInfo info2 in info.GetFiles("*", SearchOption.AllDirectories))
            {
                this.CreateSessionsForFile(info2.FullName, info.Parent.FullName);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void doQuickSearch()
        {
            if ((this.txtExec.TextLength > 1) && this.txtExec.Text.StartsWith("?", StringComparison.Ordinal))
            {
                List<ListViewItem> list = new List<ListViewItem>();
                string str = this.txtExec.Text.Substring(1).Trim();
                if (!string.IsNullOrEmpty(str))
                {
                    foreach (ListViewItem item in this.lvSessions.Items)
                    {
                        if ((item.SubItems[3].Text + item.SubItems[4].Text).IndexOf(str, StringComparison.OrdinalIgnoreCase) > -1)
                        {
                            list.Add(item);
                        }
                    }
                }
                Application.DoEvents();
                if ((this.txtExec.TextLength > 1) && (this.txtExec.Text.Substring(1).Trim() == str))
                {
                    FiddlerApplication.SuppressReportUpdates = true;
                    this.lvSessions.BeginUpdate();
                    this.lvSessions.SelectedItems.Clear();
                    foreach (ListViewItem item2 in list)
                    {
                        item2.Selected = true;
                    }
                    this.sbpInfo.Text = string.Format("Found {0:N0} instances of '{1}'", this.lvSessions.SelectedCount, str);
                    FiddlerApplication.SuppressReportUpdates = false;
                    this.lvSessions.EndUpdate();
                }
            }
        }

        public void finishSession(Session oSession)
        {
            if (oSession != null)
            {
                ListViewItem viewItem = oSession.ViewItem;
                bool flag = oSession.ShouldBeHidden();
                if (!flag && (viewItem == null))
                {
                    this._coreAddSession(oSession, true);
                    viewItem = oSession.ViewItem;
                }
                if (flag)
                {
                    if (viewItem != null)
                    {
                        oSession.ViewItem = null;
                        this.lvSessions.RemoveOrDequeue(viewItem);
                    }
                }
                else
                {
                    this._RefreshSessionListViewItem(oSession, viewItem);
                    this.actRefreshInspectorsIfNeeded(oSession);
                }
            }
        }

        private void frmFloatingInspectors_FormClosing(object sender, FormClosingEventArgs e)
        {
            base.SuspendLayout();
            this.miViewDefault.Enabled = this.miViewWide.Enabled = this.miViewStacked.Enabled = true;
            this.splitterMain.Visible = true;
            this.pnlSessions.Width = 400;
            this.pnlInspector.Controls.Add(this.tabsViews);
            this.pnlInspector.Dock = DockStyle.Fill;
            this.btnSquish.Visible = true;
            this.miViewSquish.Enabled = true;
            this.actChangeToLayout(FiddlerApplication.Prefs.GetInt32Pref("fiddler.ui.layout.mode", 0));
            base.ResumeLayout();
            this._frmFloatingInspectors = null;
        }

        private void frmViewer_Closing(object sender, CancelEventArgs e)
        {
            FiddlerApplication.isClosing = true;
            if (this._wndForMessages != null)
            {
                this._wndForMessages.DestroyHandle();
            }
            oReportingQueueTimer.Stop();
            TabPage selectedTab = FiddlerApplication.UI.tabsViews.SelectedTab;
            if (selectedTab != null)
            {
                FiddlerApplication.Prefs.SetStringPref("fiddler.ui.lastview", selectedTab.Text);
            }
            this.actDetachProxy();
            FiddlerApplication.OnFiddlerShutdown();
            Utilities.UnregisterHotKey(base.Handle, 1);
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.QuickExec.KeepHistory", true))
            {
                this.txtExec.SaveHistory(CONFIG.GetPath("QuickExecHistory"));
            }
            CONFIG.SaveSettings(this);
            UIComposer.SavePrefs();
            FiddlerApplication._AutoResponder.SaveDefaultRules();
            base.Hide();
            if (FiddlerApplication.scriptRules != null)
            {
                FiddlerApplication.scriptRules.Retire();
            }
            if (FiddlerApplication.oExtensions != null)
            {
                FiddlerApplication.oExtensions.Dispose();
            }
            CertMaker.DoDispose();
            FiddlerApplication._Prefs.Close();
        }

        private void frmViewer_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Q) && ((e.Modifiers == Keys.Alt) || (e.Modifiers == Keys.Control)))
            {
                e.SuppressKeyPress = e.Handled = true;
                this.txtExec.Focus();
            }
            else if (e.KeyData == (Keys.Control | Keys.Shift | Keys.Delete))
            {
                e.SuppressKeyPress = e.Handled = true;
                this.actClearWinINETCache();
            }
            else if (e.Modifiers == Keys.Control)
            {
                switch (e.KeyCode)
                {
                    case Keys.Oemplus:
                        {
                            float flFontSize = Math.Min((float)32f, (float)(CONFIG.flFontSize + ((float)1.0)));
                            this.actSetFontSize(flFontSize);
                            e.Handled = true;
                            return;
                        }
                    case Keys.Oemcomma:
                    case Keys.Right:
                        return;

                    case Keys.OemMinus:
                        {
                            float num4 = Math.Max((float)7f, (float)(CONFIG.flFontSize - ((float)1.0)));
                            this.actSetFontSize(num4);
                            e.Handled = true;
                            return;
                        }
                    case Keys.T:
                        this.ActivateRequestInspector("TEXTVIEW");
                        this.ActivateResponseInspector("TEXTVIEW");
                        e.Handled = true;
                        return;

                    case Keys.H:
                        this.ActivateRequestInspector("HEADERS");
                        this.ActivateResponseInspector("HEADERS");
                        e.Handled = true;
                        return;

                    case Keys.Up:
                        {
                            int num2 = this.lvSessions.Items.Count - 1;
                            if (this.lvSessions.SelectedCount > 0)
                            {
                                num2 = this.lvSessions.SelectedIndices[0] - 1;
                            }
                            if (0 <= num2)
                            {
                                FiddlerApplication.SuppressReportUpdates = true;
                                this.lvSessions.SelectedItems.Clear();
                                FiddlerApplication.SuppressReportUpdates = false;
                                this.lvSessions.Items[num2].Selected = true;
                                this.lvSessions.Items[num2].Focused = true;
                                this.lvSessions.Items[num2].EnsureVisible();
                            }
                            e.Handled = true;
                            return;
                        }
                    case Keys.Down:
                        {
                            int num = 0;
                            if (this.lvSessions.SelectedCount > 0)
                            {
                                num = this.lvSessions.SelectedIndices[0] + 1;
                            }
                            if (this.lvSessions.Items.Count > num)
                            {
                                FiddlerApplication.SuppressReportUpdates = true;
                                this.lvSessions.SelectedItems.Clear();
                                FiddlerApplication.SuppressReportUpdates = false;
                                this.lvSessions.Items[num].Selected = true;
                                this.lvSessions.Items[num].Focused = true;
                                this.lvSessions.Items[num].EnsureVisible();
                            }
                            e.Handled = true;
                            return;
                        }
                    case Keys.D0:
                        if (!this.lvSessions.Focused)
                        {
                            this.actSetFontSize(8.25f);
                            e.Handled = true;
                            return;
                        }
                        return;
                }
            }
        }

        private void frmViewer_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            this._wndForMessages = new HiddenMessagingWindow(base.Handle);
            FiddlerApplication.Reporter = new Report();
            FiddlerApplication.Reporter.Parent = this.pageStatistics;
            FiddlerApplication.Reporter.Dock = DockStyle.Fill;
            this.txtExec.OnExecute += new ExecuteHandler(this.txtExec_OnExecute);
            this.actSetFontSize(CONFIG.flFontSize);
            CONFIG.PerformISAFirewallCheck();
            CONFIG.PerformProxySettingsPerUserCheck();
            FiddlerApplication._frmSplash.IndicateProgress("Loading Inspectors...");
            FiddlerApplication.oInspectors = new Inspectors(this.tabsRequest, this.tabsResponse, this);
            FiddlerApplication._frmSplash.IndicateProgress("Loading Extensions...");
            CONFIG.EnsureFoldersExist();
            this.dlgSaveZip.InitialDirectory = this.dlgLoadZip.InitialDirectory = CONFIG.GetPath("Captures");
            FiddlerApplication.oExtensions = new FiddlerExtensions();
            this._initImportExportMenu();
            this._initBookMenu();
            this.oSAZMRU = new MRU(CONFIG.GetRegPath("MRU"), FiddlerApplication.Prefs.GetInt32Pref("fiddler.ui.mru.max", 0x10));
            if (CONFIG.bLoadScript)
            {
                FiddlerApplication._frmSplash.IndicateProgress("Loading Scripting...");
                FiddlerApplication.scriptRules = new FiddlerScript();
                this.actLoadScripts();
            }
            FiddlerApplication._frmSplash.IndicateProgress("Starting Proxy...");
            FiddlerApplication.oProxy.DetachedUnexpectedly += new EventHandler(this.WhenDetachedUnexpectedly);
            if (FiddlerApplication.oProxy.Start(CONFIG.ListenPort, CONFIG.bAllowRemoteConnections))
            {
                FiddlerApplication._frmSplash.IndicateProgress("Looking up gateway...");
                FiddlerApplication.oProxy.CollectConnectoidAndGatewayInfo();
                if (CONFIG.bAttachOnBoot && (Environment.CommandLine.IndexOf("noattach", StringComparison.OrdinalIgnoreCase) < 1))
                {
                    if (CONFIG.ListenPort == 0)
                    {
                        CONFIG.bUsingPortOverride = true;
                        CONFIG.ListenPort = FiddlerApplication.oProxy.ListenPort;
                    }
                    FiddlerApplication._frmSplash.IndicateProgress("Attaching...");
                    this.actAttachProxy(false);
                }
            }
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.filters.ResetOnRestart", false))
            {
                FiddlerApplication.Prefs.RemovePref("fiddler.ui.rules.hideimages");
                FiddlerApplication.Prefs.RemovePref("fiddler.ui.rules.hideconnects");
            }
            this.UpdateUIFromPrefs();
            FiddlerApplication.Prefs.AddWatcher("fiddler.ui.", new EventHandler<PrefChangeEventArgs>(this.OnPrefChange));
            this.miRulesBreakpointsIgnoreImages.Checked = !CONFIG.bBreakOnImages;
            this.uihlpUpdateProcessFilterStatus();
            base.SuspendLayout();
            CONFIG.RetrieveFormSettings(this);
            FiddlerToolbar.DisplayIfNeeded();
            this.miViewToolbar.Checked = FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.toolbar.visible", true);
            FiddlerApplication.oAutoResponder.AddToUI();
            if (CONFIG.bIsViewOnly)
            {
                FiddlerApplication.UI.Text = "Fiddler Viewer";
                FiddlerApplication.UI.pnlSessions.BackColor = System.Drawing.Color.FromArgb(200, 220, 250);
                FiddlerApplication.UI.miCaptureEnabled.Enabled = false;
                FiddlerApplication.UI.miToolsOptions.Enabled = false;
                FiddlerApplication.UI.notifyIcon.Text = "Fiddler Viewer";
                FiddlerApplication.UI.notifyIcon.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[0x13]);
                FiddlerApplication.UI.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[0x13]);
                FiddlerApplication.UI.sbpCapture.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[0x13]);
                FiddlerApplication.UI.sbpCapture.Text = "Viewer Mode";
                FiddlerApplication.UI.sbpCapture.Style = StatusBarPanelStyle.Text;
                FiddlerApplication.UI.sbpProcessFilter.Text = string.Empty;
            }
            base.ResumeLayout();
            Application.DoEvents();
            if (CONFIG.QuietMode)
            {
                base.ShowInTaskbar = false;
                base.WindowState = FormWindowState.Minimized;
            }
            else
            {
                base.Visible = true;
            }
            FiddlerApplication._frmSplash.Close();
            FiddlerApplication._frmSplash = null;
            if (CONFIG.bAlwaysShowTrayIcon)
            {
                this.notifyIcon.Visible = true;
            }
            if ((CONFIG.bVersionCheck && !CONFIG.QuietMode) && (!CONFIG.bIsViewOnly && (Environment.CommandLine.IndexOf("noversioncheck", StringComparison.OrdinalIgnoreCase) < 1)))
            {
                Thread thread = new Thread(new ThreadStart(this.actCheckForUpdatesQuiet));
                thread.IsBackground = true;
                thread.Start();
            }
            oReportingQueueTimer.Interval = CONFIG.iReporterUpdateInterval;
            oReportingQueueTimer.Tick += new EventHandler(this.oReportingQueueTimer_Tick);
            this.lvSessions.OnSessionsAdded = (SimpleEventHandler)Delegate.Combine(this.lvSessions.OnSessionsAdded, new SimpleEventHandler(this.lvSessions_OnSessionsAdded));
            if (!CONFIG.bIsViewOnly)
            {
                Utilities.RegisterHotKey(FiddlerApplication._frmMain.Handle, 1, CONFIG.iHotkeyMod, CONFIG.iHotkey);
            }
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.QuickExec.KeepHistory", true))
            {
                this.txtExec.LoadHistory(CONFIG.GetPath("QuickExecHistory"));
            }
            FiddlerApplication.OnFiddlerBoot();
            if (!FiddlerApplication.isClosing)
            {
                if (!CONFIG.bRevertToDefaultLayout)
                {
                    Utilities.activateTabByTitle(FiddlerApplication.Prefs.GetStringPref("fiddler.ui.lastview", "Statistics"), FiddlerApplication.UI.tabsViews);
                }
                this._LoadAnySAZSpecifiedViaCommandLine();
                this.txtExec.Focus();
                this._VerifyFiddlerIsFresh();
            }
        }

        private IRequestInspector2 GetActiveRequestInspector()
        {
            if (this.tabsRequest.TabCount > 0)
            {
                TabPage selectedTab = this.tabsRequest.SelectedTab;
                if ((selectedTab != null) && (selectedTab.Tag != null))
                {
                    return (IRequestInspector2)selectedTab.Tag;
                }
            }
            return null;
        }

        private IResponseInspector2 GetActiveResponseInspector()
        {
            if (this.tabsResponse.TabCount > 0)
            {
                TabPage selectedTab = this.tabsResponse.SelectedTab;
                if ((selectedTab != null) && (selectedTab.Tag != null))
                {
                    return (IResponseInspector2)selectedTab.Tag;
                }
            }
            return null;
        }

        [CodeDescription("Returns a Session[] array containing all sessions. Note: returns an empty non-null array if no sessions selected")]
        public Session[] GetAllSessions()
        {
            Session[] sessionArray = new Session[this.lvSessions.Items.Count];
            for (int i = 0; i < sessionArray.Length; i++)
            {
                sessionArray[i] = this.lvSessions.Items[i].Tag as Session;
            }
            return sessionArray;
        }

        public DialogResult GetDecision(frmAlert oAlert)
        {
            oAlert.StartPosition = FormStartPosition.CenterScreen;
            DialogResult result = oAlert.ShowDialog(this);
            oAlert.Dispose();
            return result;
        }

        private void GetDiffFormattedHeaders(HTTPHeaders h1, HTTPHeaders h2, out string sHeaders1, out string sHeaders2)
        {
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            List<HTTPHeaderItem> list = new List<HTTPHeaderItem>();
            List<HTTPHeaderItem> list2 = new List<HTTPHeaderItem>();
            foreach (HTTPHeaderItem item in h1)
            {
                list.Add((HTTPHeaderItem)item.Clone());
            }
            foreach (HTTPHeaderItem item2 in h2)
            {
                list2.Add((HTTPHeaderItem)item2.Clone());
            }
            foreach (HTTPHeaderItem item3 in list)
            {
                string name = item3.Name;
                string str2 = item3.Value;
                foreach (HTTPHeaderItem item4 in list2)
                {
                    if ((item4.Name == name) && (item4.Value == str2))
                    {
                        builder.AppendFormat("{0}: {1}\r\n", name, str2);
                        builder2.AppendFormat("{0}: {1}\r\n", name, str2);
                        item3.Name = string.Empty;
                        item3.Value = string.Empty;
                        list2.Remove(item4);
                        break;
                    }
                }
            }
            foreach (HTTPHeaderItem item5 in list)
            {
                string str3 = item5.Name;
                string str4 = item5.Value;
                if (!string.IsNullOrEmpty(str3) || !string.IsNullOrEmpty(str4))
                {
                    foreach (HTTPHeaderItem item6 in list2)
                    {
                        if (item6.Name == str3)
                        {
                            int length = getFirstMismatchedCharacter(str4, item6.Value);
                            if (length > -1)
                            {
                                builder.AppendFormat("{0}: {1}\r\n>>\t{2}\r\n\r\n", str3, str4.Substring(0, length), str4.Substring(length, str4.Length - length));
                                builder2.AppendFormat("{0}: {1}\r\n>>\t{2}\r\n\r\n", str3, item6.Value.Substring(0, length), item6.Value.Substring(length, item6.Value.Length - length));
                            }
                            else
                            {
                                builder.AppendFormat("{0}: {1}\r\n", str3, str4);
                                builder2.AppendFormat("{0}: {1}\r\n", str3, item6.Value);
                            }
                            item5.Name = string.Empty;
                            item5.Value = string.Empty;
                            list2.Remove(item6);
                            break;
                        }
                    }
                }
            }
            foreach (HTTPHeaderItem item7 in list)
            {
                string str5 = item7.Name;
                string str6 = item7.Value;
                if (!string.IsNullOrEmpty(str5) || !string.IsNullOrEmpty(str6))
                {
                    builder.AppendFormat("{0}: {1}\r\n", str5, str6);
                    builder2.AppendLine();
                }
            }
            foreach (HTTPHeaderItem item8 in list2)
            {
                string str7 = item8.Name;
                string str8 = item8.Value;
                builder2.AppendFormat("{0}: {1}\r\n", str7, str8);
                builder.AppendLine();
            }
            sHeaders1 = builder.ToString();
            sHeaders2 = builder2.ToString();
        }

        private static int getFirstMismatchedCharacter(string s1, string s2)
        {
            if (s1 == s2)
            {
                return -1;
            }
            int num = 0;
            int length = s1.Length;
            int num3 = s2.Length;
            while ((num < length) && (num < num3))
            {
                if (s1[num] != s2[num])
                {
                    return num;
                }
                num++;
            }
            return num;
        }

        [CodeDescription("Returns the first of the selected sessions, or null if no selected sessions")]
        public Session GetFirstSelectedSession()
        {
            if (this.lvSessions.SelectedCount > 0)
            {
                return (this.lvSessions.SelectedItems[0].Tag as Session);
            }
            return null;
        }

        [CodeDescription("Returns a Session[] array containing all of the selected sessions. Note: returns a non-null empty array if no sessions selected")]
        public Session[] GetSelectedSessions()
        {
            ListView.SelectedListViewItemCollection selectedItems = this.lvSessions.SelectedItems;
            Session[] sessionArray = new Session[selectedItems.Count];
            int index = 0;
            foreach (ListViewItem item in selectedItems)
            {
                sessionArray[index] = item.Tag as Session;
                index++;
            }
            return sessionArray;
        }

        [CodeDescription("Returns a Session[] array containing all (up to specified maximum #) of selected sessions. Note: returns a non-null empty array if no sessions selected")]
        public Session[] GetSelectedSessions(int iMax)
        {
            if (iMax < 0)
            {
                return new Session[0];
            }
            ListView.SelectedListViewItemCollection selectedItems = this.lvSessions.SelectedItems;
            Session[] sessionArray = new Session[Math.Min(iMax, selectedItems.Count)];
            int index = 0;
            foreach (ListViewItem item in selectedItems)
            {
                sessionArray[index] = item.Tag as Session;
                index++;
                if (index >= iMax)
                {
                    return sessionArray;
                }
            }
            return sessionArray;
        }

        internal DialogResult GetUpdateDecision(frmUpdate oUpdatePrompt)
        {
            if (base.InvokeRequired)
            {
                return (DialogResult)base.Invoke(new getUpdateDecisionDelegate(this.GetUpdateDecision), new object[] { oUpdatePrompt });
            }
            DialogResult result = oUpdatePrompt.ShowDialog(this);
            oUpdatePrompt.Dispose();
            return result;
        }

        internal void HandleWMCopyData(Message m)
        {
            Utilities.COPYDATASTRUCT lParam = (Utilities.COPYDATASTRUCT)m.GetLParam(typeof(Utilities.COPYDATASTRUCT));
            if (((((long)lParam.dwData) >= 0xeefaL) && (((long)lParam.dwData) <= 0xeefdL)) && (lParam.cbData >= 1))
            {
                byte[] destination = new byte[lParam.cbData];
                Marshal.Copy(lParam.lpData, destination, 0, lParam.cbData);
                long dwData = (long)lParam.dwData;
                if ((dwData <= 0xeefdL) && (dwData >= 0xeefaL))
                {
                    string str;
                    switch (((int)(dwData - 0xeefaL)))
                    {
                        case 0:
                            str = Encoding.Unicode.GetString(destination);
                            this.actLoadSessionArchive(str);
                            return;

                        case 1:
                            return;

                        case 2:
                            str = Encoding.Default.GetString(destination);
                            FiddlerApplication.UI.actQuickExec(str);
                            return;

                        case 3:
                            str = Encoding.Unicode.GetString(destination);
                            FiddlerApplication.UI.actQuickExec(str);
                            return;
                    }
                }
            }
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(frmViewer));
            this.mnuMain = new MainMenu(this.components);
            this.mnuFile = new MenuItem();
            this.miCaptureEnabled = new MenuItem();
            this.menuItem16 = new MenuItem();
            this.miFileNew = new MenuItem();
            this.miFileLoad = new MenuItem();
            this.mnuFileMRU = new MenuItem();
            this.miFileMRUSplit = new MenuItem();
            this.miFileMRUClear = new MenuItem();
            this.miFileMRUPrune = new MenuItem();
            this.mnuFileSave = new MenuItem();
            this.miFileSaveAllSessions = new MenuItem();
            this.menuItem32 = new MenuItem();
            this.mnuFileSaveSessions = new MenuItem();
            this.miFileSaveZip = new MenuItem();
            this.miFileSaveSession = new MenuItem();
            this.menuItem26 = new MenuItem();
            this.miFileSaveHeaders = new MenuItem();
            this.mnuFileSaveRequest = new MenuItem();
            this.miFileSaveRequest = new MenuItem();
            this.miFileSaveRequestBody = new MenuItem();
            this.mnuFileSaveResponse = new MenuItem();
            this.miFileSaveResponse = new MenuItem();
            this.miFileSaveResponseBody = new MenuItem();
            this.miFileSaveAndOpenBody = new MenuItem();
            this.menuItem7 = new MenuItem();
            this.miFileExit = new MenuItem();
            this.mnuEdit = new MenuItem();
            this.mnuEditCopy = new MenuItem();
            this.miEditCopySession = new MenuItem();
            this.miEditCopyUrl = new MenuItem();
            this.miEditCopyHeaders = new MenuItem();
            this.miEditCopyFullSummary = new MenuItem();
            this.miEditCopyTerseSummary = new MenuItem();
            this.mnuEditRemove = new MenuItem();
            this.miEditRemoveSelected = new MenuItem();
            this.miEditRemoveUnselected = new MenuItem();
            this.miEditRemoveAll = new MenuItem();
            this.miEditSelectAll = new MenuItem();
            this.miEditPaste = new MenuItem();
            this.miEditSplit1 = new MenuItem();
            this.mnuEditMark = new MenuItem();
            this.miEditMarkRed = new MenuItem();
            this.miEditMarkBlue = new MenuItem();
            this.miEditMarkGold = new MenuItem();
            this.miEditMarkGreen = new MenuItem();
            this.miEditMarkOrange = new MenuItem();
            this.miEditMarkPurple = new MenuItem();
            this.menuItem21 = new MenuItem();
            this.miEditMarkUnmark = new MenuItem();
            this.miEditUnlock = new MenuItem();
            this.miEditDivider = new MenuItem();
            this.miEditFind = new MenuItem();
            this.mnuRules = new MenuItem();
            this.miManipulateIgnoreImages = new MenuItem();
            this.miRulesIgnoreConnects = new MenuItem();
            this.miRulesSplit1 = new MenuItem();
            this.miRulesBreakAt = new MenuItem();
            this.miRulesBreakAtRequest = new MenuItem();
            this.miRulesBreakAtResponse = new MenuItem();
            this.miRulesBreakAtNothing = new MenuItem();
            this.menuItem18 = new MenuItem();
            this.miRulesBreakpointsIgnoreImages = new MenuItem();
            this.miCaptureRules = new MenuItem();
            this.miCaptureSplit = new MenuItem();
            this.miManipulateRequireProxyAuth = new MenuItem();
            this.miManipulateGZIP = new MenuItem();
            this.miRulesRemoveEncoding = new MenuItem();
            this.mnuTools = new MenuItem();
            this.miToolsOptions = new MenuItem();
            this.miToolsInternetOptions = new MenuItem();
            this.miToolsSplit1 = new MenuItem();
            this.miToolsClearCache = new MenuItem();
            this.miToolsClearCookies = new MenuItem();
            this.miToolsSplit2 = new MenuItem();
            this.miToolsEncodeDecode = new MenuItem();
            this.miToolsCompare = new MenuItem();
            this.miToolsSplitCustom = new MenuItem();
            this.mnuView = new MenuItem();
            this.miViewToolbar = new MenuItem();
            this.miViewSplit1 = new MenuItem();
            this.miViewDefault = new MenuItem();
            this.miViewStacked = new MenuItem();
            this.miViewWide = new MenuItem();
            this.menuItem1 = new MenuItem();
            this.miViewStatistics = new MenuItem();
            this.miViewInspector = new MenuItem();
            this.miViewBuilder = new MenuItem();
            this.miViewSplit2 = new MenuItem();
            this.miViewMinimizeToTray = new MenuItem();
            this.miViewStayOnTop = new MenuItem();
            this.miViewSplit3 = new MenuItem();
            this.miViewSquish = new MenuItem();
            this.miViewAutoScroll = new MenuItem();
            this.miViewRefresh = new MenuItem();
            this.mnuHelp = new MenuItem();
            this.miHelpContents = new MenuItem();
            this.miHelpCommunity = new MenuItem();
            this.miHelpSplit1 = new MenuItem();
            this.miHelpHTTP = new MenuItem();
            this.miHelpSplit2 = new MenuItem();
            this.miHelpShowFiltered = new MenuItem();
            this.miHelpUpdates = new MenuItem();
            this.miHelpReportBug = new MenuItem();
            this.miHelpSplit3 = new MenuItem();
            this.miHelpAbout = new MenuItem();
            this.mnuSessionContext = new ContextMenu();
            this.miSessionListScroll = new MenuItem();
            this.miSessionContextSplit = new MenuItem();
            this.miSessionCopy = new MenuItem();
            this.miSessionCopyURL = new MenuItem();
            this.miSessionCopyColumn = new MenuItem();
            this.miSessionCopyHeadlines = new MenuItem();
            this.menuItem19 = new MenuItem();
            this.miSessionCopyHeaders = new MenuItem();
            this.menuItem20 = new MenuItem();
            this.miSessionCopyEntire = new MenuItem();
            this.miSessionCopyResponseAsDataURI = new MenuItem();
            this.miSessionCopySummary = new MenuItem();
            this.miSessionSave = new MenuItem();
            this.mnuContextSaveSessions = new MenuItem();
            this.miSessionSaveToZip = new MenuItem();
            this.miSessionSaveEntire = new MenuItem();
            this.menuItem28 = new MenuItem();
            this.miSessionSaveHeaders = new MenuItem();
            this.miContextSaveSplitter = new MenuItem();
            this.mnuContextSaveRequest = new MenuItem();
            this.miSessionSaveFullRequest = new MenuItem();
            this.miSessionSaveRequestBody = new MenuItem();
            this.mnuContextSaveResponse = new MenuItem();
            this.miSessionSaveFullResponse = new MenuItem();
            this.miSessionSaveResponseBody = new MenuItem();
            this.miContextSaveAndOpenBody = new MenuItem();
            this.miSessionRemove = new MenuItem();
            this.miSessionRemoveSelected = new MenuItem();
            this.miSessionRemoveUnselected = new MenuItem();
            this.miSessionRemoveAll = new MenuItem();
            this.miSessionFilter = new MenuItem();
            this.miSessionSplit2 = new MenuItem();
            this.miSessionAddComment = new MenuItem();
            this.miSessionMark = new MenuItem();
            this.miSessionMarkRed = new MenuItem();
            this.miSessionMarkBlue = new MenuItem();
            this.miSessionMarkGold = new MenuItem();
            this.miSessionMarkGreen = new MenuItem();
            this.miSessionMarkOrange = new MenuItem();
            this.miSessionMarkPurple = new MenuItem();
            this.miContextMarkSplit = new MenuItem();
            this.miSessionMarkUnmark = new MenuItem();
            this.miSessionReplay = new MenuItem();
            this.miSessionReissueRequests = new MenuItem();
            this.miSessionReissueUnconditionally = new MenuItem();
            this.miSessionReissueEdited = new MenuItem();
            this.miSessionReissueComposer = new MenuItem();
            this.miReissueSplit = new MenuItem();
            this.miSessionReissueInIE = new MenuItem();
            this.miSessionSelect = new MenuItem();
            this.miSessionSelectParent = new MenuItem();
            this.miSessionSelectChildren = new MenuItem();
            this.miSessionSelectDuplicates = new MenuItem();
            this.miSessionWinDiff = new MenuItem();
            this.miSessionCOMETPeek = new MenuItem();
            this.miSessionAbort = new MenuItem();
            this.miSessionReplayResponse = new MenuItem();
            this.miSessionUnlock = new MenuItem();
            this.miSessionSplit = new MenuItem();
            this.miSessionInspectNewWindow = new MenuItem();
            this.miSessionProperties = new MenuItem();
            this.imglSessionIcons = new ImageList(this.components);
            this.sbStatus = new StatusBar();
            this.sbpCapture = new StatusBarPanel();
            this.sbpProcessFilter = new StatusBarPanel();
            this.sbpBreakpoints = new StatusBarPanel();
            this.sbpSelCount = new StatusBarPanel();
            this.sbpInfo = new StatusBarPanel();
            this.pnlSessions = new Panel();
            this.lvSessions = new SessionListView();
            this.colID = new ColumnHeader();
            this.colStatus = new ColumnHeader();
            this.colProtocol = new ColumnHeader();
            this.colHost = new ColumnHeader();
            this.colRequest = new ColumnHeader();
            this.colResponseSize = new ColumnHeader();
            this.colExpires = new ColumnHeader();
            this.colContentType = new ColumnHeader();
            this.colProcess = new ColumnHeader();
            this.colComments = new ColumnHeader();
            this.colCustom = new ColumnHeader();
            this.btnSquish = new Button();
            this.lblSessions = new Label();
            this.txtExec = new QuickExec();
            this.splitterMain = new Splitter();
            this.pnlInspector = new Panel();
            this.tabsViews = new TabControl();
            this.pageStatistics = new TabPage();
            this.pageInspector = new TabPage();
            this.tabsResponse = new TabControl();
            this.mnuInspectorsContext = new ContextMenu();
            this.miInspectorProperties = new MenuItem();
            this.miInspectorHide = new MenuItem();
            this.pnlInfoTip = new Panel();
            this.btnDecodeResponse = new Button();
            this.pnlSessionControls = new Panel();
            this.cbxLoadFrom = new ComboBox();
            this.lblBreakpoint = new Label();
            this.btnTamperSendClient = new Button();
            this.btnTamperSendServer = new Button();
            this.splitterInspector = new Splitter();
            this.tabsRequest = new TabControl();
            this.pnlInfoTipRequest = new Panel();
            this.btnDecodeRequest = new Button();
            this.pnlInfoBar = new Panel();
            this.btnPromptHTTPS = new Button();
            this.pageResponder = new TabPage();
            this.pageBuilder = new TabPage();
            this.dlgSaveBinary = new SaveFileDialog();
            this.notifyIcon = new NotifyIcon(this.components);
            this.mnuNotify = new ContextMenuStrip(this.components);
            this.miNotifyRestore = new ToolStripMenuItem();
            this.miNotifyCapturing = new ToolStripMenuItem();
            this.toolStripMenuItem1 = new ToolStripSeparator();
            this.miNotifyExit = new ToolStripMenuItem();
            this.dlgSaveZip = new SaveFileDialog();
            this.dlgLoadZip = new OpenFileDialog();
            this.imglToolbar = new ImageList(this.components);
            this.pnlTopNotice = new Panel();
            this.btnWarnDetached = new Button();
            this.sbpCapture.BeginInit();
            this.sbpProcessFilter.BeginInit();
            this.sbpBreakpoints.BeginInit();
            this.sbpSelCount.BeginInit();
            this.sbpInfo.BeginInit();
            this.pnlSessions.SuspendLayout();
            this.pnlInspector.SuspendLayout();
            this.tabsViews.SuspendLayout();
            this.pageInspector.SuspendLayout();
            this.pnlInfoTip.SuspendLayout();
            this.pnlSessionControls.SuspendLayout();
            this.pnlInfoTipRequest.SuspendLayout();
            this.pnlInfoBar.SuspendLayout();
            this.mnuNotify.SuspendLayout();
            this.pnlTopNotice.SuspendLayout();
            base.SuspendLayout();
            this.mnuMain.MenuItems.AddRange(new MenuItem[] { this.mnuFile, this.mnuEdit, this.mnuRules, this.mnuTools, this.mnuView, this.mnuHelp });
            this.mnuFile.Index = 0;
            this.mnuFile.MenuItems.AddRange(new MenuItem[] { this.miCaptureEnabled, this.menuItem16, this.miFileNew, this.miFileLoad, this.mnuFileMRU, this.mnuFileSave, this.menuItem7, this.miFileExit });
            this.mnuFile.Text = "&File";
            this.mnuFile.Popup += new EventHandler(this.mnuFile_Popup);
            this.miCaptureEnabled.Index = 0;
            this.miCaptureEnabled.Shortcut = Shortcut.F12;
            this.miCaptureEnabled.Text = "&Capture Traffic";
            this.miCaptureEnabled.Click += new EventHandler(this.miCaptureEnabled_Click);
            this.menuItem16.Index = 1;
            this.menuItem16.Text = "-";
            this.miFileNew.Index = 2;
            this.miFileNew.Text = "&New Viewer...";
            this.miFileNew.Click += new EventHandler(this.miFileNew_Click);
            this.miFileLoad.Index = 3;
            this.miFileLoad.Text = "L&oad Archive...";
            this.miFileLoad.Click += new EventHandler(this.miFileLoad_Click);
            this.mnuFileMRU.Index = 4;
            this.mnuFileMRU.MenuItems.AddRange(new MenuItem[] { this.miFileMRUSplit, this.miFileMRUClear, this.miFileMRUPrune });
            this.mnuFileMRU.Text = "&Recent Archives";
            this.mnuFileMRU.Popup += new EventHandler(this.mnuFileMRU_Popup);
            this.miFileMRUSplit.Index = 0;
            this.miFileMRUSplit.Text = "-";
            this.miFileMRUClear.Index = 1;
            this.miFileMRUClear.Text = "Clear this &List";
            this.miFileMRUClear.Click += new EventHandler(this.miFileMRUClear_Click);
            this.miFileMRUPrune.Index = 2;
            this.miFileMRUPrune.Text = "&Prune Obsolete";
            this.miFileMRUPrune.Click += new EventHandler(this.miFileMRUPrune_Click);
            this.mnuFileSave.Index = 5;
            this.mnuFileSave.MenuItems.AddRange(new MenuItem[] { this.miFileSaveAllSessions, this.menuItem32, this.mnuFileSaveSessions, this.mnuFileSaveRequest, this.mnuFileSaveResponse });
            this.mnuFileSave.Text = "&Save";
            this.mnuFileSave.Popup += new EventHandler(this.mnuFileSave_Popup);
            this.miFileSaveAllSessions.Index = 0;
            this.miFileSaveAllSessions.Text = "&All Sessions...";
            this.miFileSaveAllSessions.Click += new EventHandler(this.miFileSaveAllSessions_Click);
            this.menuItem32.Index = 1;
            this.menuItem32.Text = "-";
            this.mnuFileSaveSessions.Index = 2;
            this.mnuFileSaveSessions.MenuItems.AddRange(new MenuItem[] { this.miFileSaveZip, this.miFileSaveSession, this.menuItem26, this.miFileSaveHeaders });
            this.mnuFileSaveSessions.Text = "Selected &Sessions";
            this.miFileSaveZip.DefaultItem = true;
            this.miFileSaveZip.Index = 0;
            this.miFileSaveZip.Text = "in Archive&Zip...";
            this.miFileSaveZip.Click += new EventHandler(this.miSessionSaveToZip_Click);
            this.miFileSaveSession.Index = 1;
            this.miFileSaveSession.Text = "as &Text...";
            this.miFileSaveSession.Click += new EventHandler(this.miSessionSaveEntire_Click);
            this.menuItem26.Index = 2;
            this.menuItem26.Text = "-";
            this.miFileSaveHeaders.Index = 3;
            this.miFileSaveHeaders.Text = "as Text (&Headers only)...";
            this.miFileSaveHeaders.Click += new EventHandler(this.miSessionSaveHeaders_Click);
            this.mnuFileSaveRequest.Index = 3;
            this.mnuFileSaveRequest.MenuItems.AddRange(new MenuItem[] { this.miFileSaveRequest, this.miFileSaveRequestBody });
            this.mnuFileSaveRequest.Text = "&Request";
            this.miFileSaveRequest.Index = 0;
            this.miFileSaveRequest.Text = "&Entire Request...";
            this.miFileSaveRequest.Click += new EventHandler(this.miSessionSaveFullRequest_Click);
            this.miFileSaveRequestBody.Index = 1;
            this.miFileSaveRequestBody.Text = "Request &Body...";
            this.miFileSaveRequestBody.Click += new EventHandler(this.miSessionSaveRequestBody_Click);
            this.mnuFileSaveResponse.Index = 4;
            this.mnuFileSaveResponse.MenuItems.AddRange(new MenuItem[] { this.miFileSaveResponse, this.miFileSaveResponseBody, this.miFileSaveAndOpenBody });
            this.mnuFileSaveResponse.Text = "R&esponse";
            this.miFileSaveResponse.Index = 0;
            this.miFileSaveResponse.Text = "&Entire Response...";
            this.miFileSaveResponse.Click += new EventHandler(this.miSessionSaveFullResponse_Click);
            this.miFileSaveResponseBody.Index = 1;
            this.miFileSaveResponseBody.Text = "&Response Body...";
            this.miFileSaveResponseBody.Click += new EventHandler(this.miSessionSaveResponseBody_Click);
            this.miFileSaveAndOpenBody.Index = 2;
            this.miFileSaveAndOpenBody.Text = "... and Open as Local &File";
            this.miFileSaveAndOpenBody.Click += new EventHandler(this.miFileSaveAndOpenBody_Click);
            this.menuItem7.Index = 6;
            this.menuItem7.Text = "-";
            this.miFileExit.Index = 7;
            this.miFileExit.Text = "E&xit";
            this.miFileExit.Click += new EventHandler(this.miExit_Click);
            this.mnuEdit.Index = 1;
            this.mnuEdit.MenuItems.AddRange(new MenuItem[] { this.mnuEditCopy, this.mnuEditRemove, this.miEditSelectAll, this.miEditPaste, this.miEditSplit1, this.mnuEditMark, this.miEditUnlock, this.miEditDivider, this.miEditFind });
            this.mnuEdit.Text = "&Edit";
            this.mnuEdit.Popup += new EventHandler(this.mnuEdit_Popup);
            this.mnuEditCopy.Index = 0;
            this.mnuEditCopy.MenuItems.AddRange(new MenuItem[] { this.miEditCopySession, this.miEditCopyUrl, this.miEditCopyHeaders, this.miEditCopyFullSummary, this.miEditCopyTerseSummary });
            this.mnuEditCopy.Text = "&Copy";
            this.miEditCopySession.Index = 0;
            this.miEditCopySession.Text = "&Session\tCtrl+Shift+S";
            this.miEditCopySession.Click += new EventHandler(this.miSessionCopyEntire_Click);
            this.miEditCopyUrl.Index = 1;
            this.miEditCopyUrl.Text = "Just &Url\tCtrl+U";
            this.miEditCopyUrl.Click += new EventHandler(this.miSessionCopyURL_Click);
            this.miEditCopyHeaders.Index = 2;
            this.miEditCopyHeaders.Text = "&Headers only\tCtrl+Shift+C";
            this.miEditCopyHeaders.Click += new EventHandler(this.miSessionCopyHeaders_Click);
            this.miEditCopyFullSummary.Index = 3;
            this.miEditCopyFullSummary.Text = "&Full Summary\tCtrl+C";
            this.miEditCopyFullSummary.Click += new EventHandler(this.miSessionCopySummary_Click);
            this.miEditCopyTerseSummary.Index = 4;
            this.miEditCopyTerseSummary.Text = "&Terse Summary\tCtrl+Shift+T";
            this.miEditCopyTerseSummary.Click += new EventHandler(this.miSessionCopyHeadlines_Click);
            this.mnuEditRemove.Index = 1;
            this.mnuEditRemove.MenuItems.AddRange(new MenuItem[] { this.miEditRemoveSelected, this.miEditRemoveUnselected, this.miEditRemoveAll });
            this.mnuEditRemove.Text = "&Remove";
            this.mnuEditRemove.Popup += new EventHandler(this.mnuEditRemove_Popup);
            this.miEditRemoveSelected.Index = 0;
            this.miEditRemoveSelected.Text = "&Selected Sessions\tDel";
            this.miEditRemoveSelected.Click += new EventHandler(this.miSessionRemoveSelected_Click);
            this.miEditRemoveUnselected.Index = 1;
            this.miEditRemoveUnselected.Text = "&Unselected Sessions\tShift+Del";
            this.miEditRemoveUnselected.Click += new EventHandler(this.miSessionRemoveUnselected_Click);
            this.miEditRemoveAll.Index = 2;
            this.miEditRemoveAll.Text = "&All Sessions\tCtrl+X";
            this.miEditRemoveAll.Click += new EventHandler(this.miSessionRemoveAll_Click);
            this.miEditSelectAll.Index = 2;
            this.miEditSelectAll.Text = "Select &All\tCtrl+A";
            this.miEditSelectAll.Click += new EventHandler(this.miEditSelectAll_Click);
            this.miEditPaste.Index = 3;
            this.miEditPaste.Text = "&Paste Files as Sessions";
            this.miEditPaste.Click += new EventHandler(this.miEditPaste_Click);
            this.miEditSplit1.Index = 4;
            this.miEditSplit1.Text = "-";
            this.mnuEditMark.Index = 5;
            this.mnuEditMark.MenuItems.AddRange(new MenuItem[] { this.miEditMarkRed, this.miEditMarkBlue, this.miEditMarkGold, this.miEditMarkGreen, this.miEditMarkOrange, this.miEditMarkPurple, this.menuItem21, this.miEditMarkUnmark });
            this.mnuEditMark.Text = "&Mark";
            this.miEditMarkRed.Index = 0;
            this.miEditMarkRed.Text = "&Red\tCtrl+1";
            this.miEditMarkRed.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditMarkBlue.Index = 1;
            this.miEditMarkBlue.Text = "&Blue\tCtrl+2";
            this.miEditMarkBlue.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditMarkGold.Index = 2;
            this.miEditMarkGold.Text = "Gol&d\tCtrl+3";
            this.miEditMarkGold.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditMarkGreen.Index = 3;
            this.miEditMarkGreen.Text = "&Green\tCtrl+4";
            this.miEditMarkGreen.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditMarkOrange.Index = 4;
            this.miEditMarkOrange.Text = "&Orange\tCtrl+5";
            this.miEditMarkOrange.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditMarkPurple.Index = 5;
            this.miEditMarkPurple.Text = "&Purple\tCtrl+6";
            this.miEditMarkPurple.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.menuItem21.Index = 6;
            this.menuItem21.Text = "-";
            this.miEditMarkUnmark.Index = 7;
            this.miEditMarkUnmark.Text = "&Unmark\tCtrl+0";
            this.miEditMarkUnmark.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miEditUnlock.Index = 6;
            this.miEditUnlock.Text = "&Unlock for Editing\tF2";
            this.miEditUnlock.Click += new EventHandler(this.miEditUnlock_Click);
            this.miEditDivider.Index = 7;
            this.miEditDivider.Text = "-";
            this.miEditFind.Index = 8;
            this.miEditFind.Shortcut = Shortcut.CtrlF;
            this.miEditFind.Text = "&Find Sessions...";
            this.miEditFind.Click += new EventHandler(this.miToolsFind_Click);
            this.mnuRules.Index = 2;
            this.mnuRules.MenuItems.AddRange(new MenuItem[] { this.miManipulateIgnoreImages, this.miRulesIgnoreConnects, this.miRulesSplit1, this.miRulesBreakAt, this.miCaptureRules, this.miCaptureSplit, this.miManipulateRequireProxyAuth, this.miManipulateGZIP, this.miRulesRemoveEncoding });
            this.mnuRules.Text = "&Rules";
            this.miManipulateIgnoreImages.Index = 0;
            this.miManipulateIgnoreImages.Text = "Hide &Image Requests";
            this.miManipulateIgnoreImages.Click += new EventHandler(this.miManipulateIgnoreImages_Click);
            this.miRulesIgnoreConnects.Index = 1;
            this.miRulesIgnoreConnects.Text = "Hide &CONNECTs";
            this.miRulesIgnoreConnects.Click += new EventHandler(this.miRulesIgnoreConnects_Click);
            this.miRulesSplit1.Index = 2;
            this.miRulesSplit1.Text = "-";
            this.miRulesBreakAt.Index = 3;
            this.miRulesBreakAt.MenuItems.AddRange(new MenuItem[] { this.miRulesBreakAtRequest, this.miRulesBreakAtResponse, this.miRulesBreakAtNothing, this.menuItem18, this.miRulesBreakpointsIgnoreImages });
            this.miRulesBreakAt.Text = "Automatic Breakpoint&s";
            this.miRulesBreakAtRequest.Index = 0;
            this.miRulesBreakAtRequest.RadioCheck = true;
            this.miRulesBreakAtRequest.Shortcut = Shortcut.F11;
            this.miRulesBreakAtRequest.Text = "&Before Requests";
            this.miRulesBreakAtRequest.Click += new EventHandler(this.miBreakAtChoice_Check);
            this.miRulesBreakAtResponse.Index = 1;
            this.miRulesBreakAtResponse.RadioCheck = true;
            this.miRulesBreakAtResponse.Shortcut = Shortcut.AltF11;
            this.miRulesBreakAtResponse.Text = "&After Responses";
            this.miRulesBreakAtResponse.Click += new EventHandler(this.miBreakAtChoice_Check);
            this.miRulesBreakAtNothing.Checked = true;
            this.miRulesBreakAtNothing.Index = 2;
            this.miRulesBreakAtNothing.RadioCheck = true;
            this.miRulesBreakAtNothing.Shortcut = Shortcut.ShiftF11;
            this.miRulesBreakAtNothing.Text = "&Disabled";
            this.miRulesBreakAtNothing.Click += new EventHandler(this.miBreakAtChoice_Check);
            this.menuItem18.Index = 3;
            this.menuItem18.Text = "-";
            this.miRulesBreakpointsIgnoreImages.Checked = true;
            this.miRulesBreakpointsIgnoreImages.Index = 4;
            this.miRulesBreakpointsIgnoreImages.Text = "&Ignore Images";
            this.miRulesBreakpointsIgnoreImages.Click += new EventHandler(this.miRulesBreakpointsIgnoreImages_Click);
            this.miCaptureRules.Index = 4;
            this.miCaptureRules.Shortcut = Shortcut.CtrlR;
            this.miCaptureRules.Text = "Customize &Rules...";
            this.miCaptureRules.Click += new EventHandler(this.miCaptureRules_Click);
            this.miCaptureSplit.Index = 5;
            this.miCaptureSplit.Text = "-";
            this.miManipulateRequireProxyAuth.Index = 6;
            this.miManipulateRequireProxyAuth.Text = "Require &Proxy Authentication";
            this.miManipulateRequireProxyAuth.Click += new EventHandler(this.miManipulateRequireProxyAuth_Click);
            this.miManipulateGZIP.Index = 7;
            this.miManipulateGZIP.Text = "Apply G&ZIP Encoding";
            this.miManipulateGZIP.Click += new EventHandler(this.miManipulateGZIP_Click);
            this.miRulesRemoveEncoding.Index = 8;
            this.miRulesRemoveEncoding.Text = "Remove All &Encodings";
            this.miRulesRemoveEncoding.Click += new EventHandler(this.miRulesRemoveEncoding_Click);
            this.mnuTools.Index = 3;
            this.mnuTools.MenuItems.AddRange(new MenuItem[] { this.miToolsOptions, this.miToolsInternetOptions, this.miToolsSplit1, this.miToolsClearCache, this.miToolsClearCookies, this.miToolsSplit2, this.miToolsEncodeDecode, this.miToolsCompare, this.miToolsSplitCustom });
            this.mnuTools.Text = "&Tools";
            this.mnuTools.Popup += new EventHandler(this.mnuTools_Popup);
            this.miToolsOptions.Index = 0;
            this.miToolsOptions.Text = "&Fiddler Options...";
            this.miToolsOptions.Click += new EventHandler(this.miToolsOptions_Click);
            this.miToolsInternetOptions.Index = 1;
            this.miToolsInternetOptions.Text = "WinINET &Options...";
            this.miToolsInternetOptions.Click += new EventHandler(this.miToolsInternetOptions_Click);
            this.miToolsSplit1.Index = 2;
            this.miToolsSplit1.Text = "-";
            this.miToolsClearCache.Index = 3;
            this.miToolsClearCache.Shortcut = Shortcut.CtrlShiftX;
            this.miToolsClearCache.Text = "&Clear WinINET Cache";
            this.miToolsClearCache.Click += new EventHandler(this.miToolsClearCache_Click);
            this.miToolsClearCookies.Index = 4;
            this.miToolsClearCookies.Text = "Clear WinINET Coo&kies";
            this.miToolsClearCookies.Click += new EventHandler(this.miToolsClearCookies_Click);
            this.miToolsSplit2.Index = 5;
            this.miToolsSplit2.Text = "-";
            this.miToolsEncodeDecode.Index = 6;
            this.miToolsEncodeDecode.Shortcut = Shortcut.CtrlE;
            this.miToolsEncodeDecode.Text = "T&extWizard...";
            this.miToolsEncodeDecode.Click += new EventHandler(this.miToolsBase64_Click);
            this.miToolsCompare.Index = 7;
            this.miToolsCompare.Text = "Co&mpare Sessions\tCtrl+W";
            this.miToolsCompare.Click += new EventHandler(this.miSessionWinDiff_Click);
            this.miToolsSplitCustom.Index = 8;
            this.miToolsSplitCustom.Text = "-";
            this.mnuView.Index = 4;
            this.mnuView.MenuItems.AddRange(new MenuItem[] { this.miViewToolbar, this.miViewSplit1, this.miViewDefault, this.miViewStacked, this.miViewWide, this.menuItem1, this.miViewStatistics, this.miViewInspector, this.miViewBuilder, this.miViewSplit2, this.miViewMinimizeToTray, this.miViewStayOnTop, this.miViewSplit3, this.miViewSquish, this.miViewAutoScroll, this.miViewRefresh });
            this.mnuView.Text = "&View";
            this.miViewToolbar.Checked = true;
            this.miViewToolbar.Index = 0;
            this.miViewToolbar.Text = "Sho&w Toolbar";
            this.miViewToolbar.Click += new EventHandler(this.miViewToolbar_Click);
            this.miViewSplit1.Index = 1;
            this.miViewSplit1.Text = "-";
            this.miViewDefault.Checked = true;
            this.miViewDefault.Index = 2;
            this.miViewDefault.RadioCheck = true;
            this.miViewDefault.Text = "&Default Layout";
            this.miViewDefault.Click += new EventHandler(this.miViewLayout_Click);
            this.miViewStacked.Index = 3;
            this.miViewStacked.RadioCheck = true;
            this.miViewStacked.Text = "Stac&ked Layout";
            this.miViewStacked.Click += new EventHandler(this.miViewLayout_Click);
            this.miViewWide.Index = 4;
            this.miViewWide.RadioCheck = true;
            this.miViewWide.Text = "Wid&e Layout";
            this.miViewWide.Click += new EventHandler(this.miViewLayout_Click);
            this.menuItem1.Index = 5;
            this.menuItem1.Text = "-";
            this.miViewStatistics.Index = 6;
            this.miViewStatistics.Shortcut = Shortcut.F7;
            this.miViewStatistics.Text = "&Statistics";
            this.miViewStatistics.Click += new EventHandler(this.miViewStatistics_Click);
            this.miViewInspector.Index = 7;
            this.miViewInspector.Shortcut = Shortcut.F8;
            this.miViewInspector.Text = "&Inspectors";
            this.miViewInspector.Click += new EventHandler(this.miViewInspector_Click);
            this.miViewBuilder.Index = 8;
            this.miViewBuilder.Shortcut = Shortcut.F9;
            this.miViewBuilder.Text = "&Composer";
            this.miViewBuilder.Click += new EventHandler(this.miViewBuilder_Click);
            this.miViewSplit2.Index = 9;
            this.miViewSplit2.Text = "-";
            this.miViewMinimizeToTray.Index = 10;
            this.miViewMinimizeToTray.Shortcut = Shortcut.CtrlM;
            this.miViewMinimizeToTray.Text = "&Minimize to Tray";
            this.miViewMinimizeToTray.Click += new EventHandler(this.miFileMinimizeToTray_Click);
            this.miViewStayOnTop.Index = 11;
            this.miViewStayOnTop.Text = "Stay on &Top";
            this.miViewStayOnTop.Click += new EventHandler(this.miViewStayOnTop_Click);
            this.miViewSplit3.Index = 12;
            this.miViewSplit3.Text = "-";
            this.miViewSquish.Index = 13;
            this.miViewSquish.Shortcut = Shortcut.F6;
            this.miViewSquish.Text = "Squish Session &List";
            this.miViewSquish.Click += new EventHandler(this.miSquish_Click);
            this.miViewAutoScroll.Checked = true;
            this.miViewAutoScroll.Index = 14;
            this.miViewAutoScroll.Text = "&AutoScroll Session List";
            this.miViewAutoScroll.Click += new EventHandler(this.miViewAutoScroll_Click);
            this.miViewRefresh.Index = 15;
            this.miViewRefresh.Shortcut = Shortcut.F5;
            this.miViewRefresh.Text = "&Refresh";
            this.miViewRefresh.Click += new EventHandler(this.miViewRefresh_Click);
            this.mnuHelp.Index = 5;
            this.mnuHelp.MenuItems.AddRange(new MenuItem[] { this.miHelpContents, this.miHelpCommunity, this.miHelpSplit1, this.miHelpHTTP, this.miHelpSplit2, this.miHelpShowFiltered, this.miHelpUpdates, this.miHelpReportBug, this.miHelpSplit3, this.miHelpAbout });
            this.mnuHelp.Text = "&Help";
            this.miHelpContents.Index = 0;
            this.miHelpContents.Shortcut = Shortcut.F1;
            this.miHelpContents.Text = "Fiddler &Help";
            this.miHelpContents.Click += new EventHandler(this.miHelpContents_Click);
            this.miHelpCommunity.Index = 1;
            this.miHelpCommunity.Text = "Fiddler &Community Discussions";
            this.miHelpCommunity.Click += new EventHandler(this.miHelpCommunity_Click);
            this.miHelpSplit1.Index = 2;
            this.miHelpSplit1.Text = "-";
            this.miHelpHTTP.Index = 3;
            this.miHelpHTTP.Text = "HTTP &References";
            this.miHelpHTTP.Click += new EventHandler(this.miHelpHTTP_Click);
            this.miHelpSplit2.Index = 4;
            this.miHelpSplit2.Text = "-";
            this.miHelpShowFiltered.Index = 5;
            this.miHelpShowFiltered.Text = "&Troubleshoot Filters...";
            this.miHelpShowFiltered.Click += new EventHandler(this.miHelpShowFiltered_Click);
            this.miHelpUpdates.Index = 6;
            this.miHelpUpdates.Text = "Check for &Updates...";
            this.miHelpUpdates.Click += new EventHandler(this.miHelpUpdates_Click);
            this.miHelpReportBug.Index = 7;
            this.miHelpReportBug.Text = "&Send Feedback...";
            this.miHelpReportBug.Click += new EventHandler(this.miReportBug_Click);
            this.miHelpSplit3.Index = 8;
            this.miHelpSplit3.Text = "-";
            this.miHelpAbout.Index = 9;
            this.miHelpAbout.Text = "&About Fiddler";
            this.miHelpAbout.Click += new EventHandler(this.miHelpAbout_Click);
            this.mnuSessionContext.MenuItems.AddRange(new MenuItem[] { 
                this.miSessionListScroll, this.miSessionContextSplit, this.miSessionCopy, this.miSessionSave, this.miSessionRemove, this.miSessionFilter, this.miSessionSplit2, this.miSessionAddComment, this.miSessionMark, this.miSessionReplay, this.miSessionSelect, this.miSessionWinDiff, this.miSessionCOMETPeek, this.miSessionAbort, this.miSessionReplayResponse, this.miSessionUnlock, 
                this.miSessionSplit, this.miSessionInspectNewWindow, this.miSessionProperties
             });
            this.mnuSessionContext.Popup += new EventHandler(this.mnuSessionContext_Popup);
            this.miSessionListScroll.Checked = true;
            this.miSessionListScroll.Index = 0;
            this.miSessionListScroll.Text = "AutoScroll Session List";
            this.miSessionListScroll.Click += new EventHandler(this.miSessionListScroll_Click);
            this.miSessionContextSplit.Index = 1;
            this.miSessionContextSplit.Text = "-";
            this.miSessionCopy.Index = 2;
            this.miSessionCopy.MenuItems.AddRange(new MenuItem[] { this.miSessionCopyURL, this.miSessionCopyColumn, this.miSessionCopyHeadlines, this.menuItem19, this.miSessionCopyHeaders, this.menuItem20, this.miSessionCopyEntire, this.miSessionCopyResponseAsDataURI, this.miSessionCopySummary });
            this.miSessionCopy.Text = "&Copy";
            this.miSessionCopyURL.Index = 0;
            this.miSessionCopyURL.Text = "Just &Url\tCtrl+U";
            this.miSessionCopyURL.Click += new EventHandler(this.miSessionCopyURL_Click);
            this.miSessionCopyColumn.Index = 1;
            this.miSessionCopyColumn.Text = "This &Column";
            this.miSessionCopyColumn.Click += new EventHandler(this.miSessionCopyColumn_Click);
            this.miSessionCopyHeadlines.Index = 2;
            this.miSessionCopyHeadlines.Text = "&Terse Summary\tCtrl+Shift+T";
            this.miSessionCopyHeadlines.Click += new EventHandler(this.miSessionCopyHeadlines_Click);
            this.menuItem19.Index = 3;
            this.menuItem19.Text = "-";
            this.miSessionCopyHeaders.DefaultItem = true;
            this.miSessionCopyHeaders.Index = 4;
            this.miSessionCopyHeaders.Text = "&Headers only\tCtrl+Shift+C";
            this.miSessionCopyHeaders.Click += new EventHandler(this.miSessionCopyHeaders_Click);
            this.menuItem20.Index = 5;
            this.menuItem20.Text = "-";
            this.miSessionCopyEntire.Index = 6;
            this.miSessionCopyEntire.Text = "&Session\tCtrl+Shift+S";
            this.miSessionCopyEntire.Click += new EventHandler(this.miSessionCopyEntire_Click);
            this.miSessionCopyResponseAsDataURI.Index = 7;
            this.miSessionCopyResponseAsDataURI.Text = "Response &DataURI";
            this.miSessionCopyResponseAsDataURI.Click += new EventHandler(this.miSessionCopyResponseAsDataURI_Click);
            this.miSessionCopySummary.Index = 8;
            this.miSessionCopySummary.Text = "&Full Summary\tCtrl+C";
            this.miSessionCopySummary.Click += new EventHandler(this.miSessionCopySummary_Click);
            this.miSessionSave.Index = 3;
            this.miSessionSave.MenuItems.AddRange(new MenuItem[] { this.mnuContextSaveSessions, this.miContextSaveSplitter, this.mnuContextSaveRequest, this.mnuContextSaveResponse, this.miContextSaveAndOpenBody });
            this.miSessionSave.Text = "&Save";
            this.mnuContextSaveSessions.Index = 0;
            this.mnuContextSaveSessions.MenuItems.AddRange(new MenuItem[] { this.miSessionSaveToZip, this.miSessionSaveEntire, this.menuItem28, this.miSessionSaveHeaders });
            this.mnuContextSaveSessions.Text = "Selected &Sessions";
            this.miSessionSaveToZip.DefaultItem = true;
            this.miSessionSaveToZip.Index = 0;
            this.miSessionSaveToZip.Text = "in Archive&ZIP...";
            this.miSessionSaveToZip.Click += new EventHandler(this.miSessionSaveToZip_Click);
            this.miSessionSaveEntire.Index = 1;
            this.miSessionSaveEntire.Text = "as Text...";
            this.miSessionSaveEntire.Click += new EventHandler(this.miSessionSaveEntire_Click);
            this.menuItem28.Index = 2;
            this.menuItem28.Text = "-";
            this.miSessionSaveHeaders.Index = 3;
            this.miSessionSaveHeaders.Text = "as Text (&Headers only)...";
            this.miSessionSaveHeaders.Click += new EventHandler(this.miSessionSaveHeaders_Click);
            this.miContextSaveSplitter.Index = 1;
            this.miContextSaveSplitter.Text = "-";
            this.mnuContextSaveRequest.Index = 2;
            this.mnuContextSaveRequest.MenuItems.AddRange(new MenuItem[] { this.miSessionSaveFullRequest, this.miSessionSaveRequestBody });
            this.mnuContextSaveRequest.Text = "&Request";
            this.miSessionSaveFullRequest.DefaultItem = true;
            this.miSessionSaveFullRequest.Index = 0;
            this.miSessionSaveFullRequest.Text = "&Entire Request...";
            this.miSessionSaveFullRequest.Click += new EventHandler(this.miSessionSaveFullRequest_Click);
            this.miSessionSaveRequestBody.Index = 1;
            this.miSessionSaveRequestBody.Text = "Request &Body...";
            this.miSessionSaveRequestBody.Click += new EventHandler(this.miSessionSaveRequestBody_Click);
            this.mnuContextSaveResponse.Index = 3;
            this.mnuContextSaveResponse.MenuItems.AddRange(new MenuItem[] { this.miSessionSaveFullResponse, this.miSessionSaveResponseBody });
            this.mnuContextSaveResponse.Text = "R&esponse";
            this.miSessionSaveFullResponse.Index = 0;
            this.miSessionSaveFullResponse.Text = "&Entire Response...";
            this.miSessionSaveFullResponse.Click += new EventHandler(this.miSessionSaveFullResponse_Click);
            this.miSessionSaveResponseBody.DefaultItem = true;
            this.miSessionSaveResponseBody.Index = 1;
            this.miSessionSaveResponseBody.Text = "&Response Body...";
            this.miSessionSaveResponseBody.Click += new EventHandler(this.miSessionSaveResponseBody_Click);
            this.miContextSaveAndOpenBody.Index = 4;
            this.miContextSaveAndOpenBody.Text = "...and Open as Local &File";
            this.miContextSaveAndOpenBody.Click += new EventHandler(this.miContextSaveAndOpenBody_Click);
            this.miSessionRemove.Index = 4;
            this.miSessionRemove.MenuItems.AddRange(new MenuItem[] { this.miSessionRemoveSelected, this.miSessionRemoveUnselected, this.miSessionRemoveAll });
            this.miSessionRemove.Text = "&Remove";
            this.miSessionRemoveSelected.Index = 0;
            this.miSessionRemoveSelected.Text = "&Selected Sessions\tDel";
            this.miSessionRemoveSelected.Click += new EventHandler(this.miSessionRemoveSelected_Click);
            this.miSessionRemoveUnselected.Index = 1;
            this.miSessionRemoveUnselected.Text = "&Unselected Sessions\tShift+Del";
            this.miSessionRemoveUnselected.Click += new EventHandler(this.miSessionRemoveUnselected_Click);
            this.miSessionRemoveAll.Index = 2;
            this.miSessionRemoveAll.Text = "&All Sessions\tCtrl+X";
            this.miSessionRemoveAll.Click += new EventHandler(this.miSessionRemoveAll_Click);
            this.miSessionFilter.Index = 5;
            this.miSessionFilter.Text = "&Filter";
            this.miSessionFilter.Popup += new EventHandler(this.miSessionFilter_Popup);
            this.miSessionSplit2.Index = 6;
            this.miSessionSplit2.Text = "-";
            this.miSessionAddComment.Index = 7;
            this.miSessionAddComment.Text = "Commen&t...\tM";
            this.miSessionAddComment.Click += new EventHandler(this.miSessionAddComment_Click);
            this.miSessionMark.Index = 8;
            this.miSessionMark.MenuItems.AddRange(new MenuItem[] { this.miSessionMarkRed, this.miSessionMarkBlue, this.miSessionMarkGold, this.miSessionMarkGreen, this.miSessionMarkOrange, this.miSessionMarkPurple, this.miContextMarkSplit, this.miSessionMarkUnmark });
            this.miSessionMark.Text = "&Mark";
            this.miSessionMarkRed.Index = 0;
            this.miSessionMarkRed.Text = "&Red\tCtrl+1";
            this.miSessionMarkRed.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionMarkBlue.Index = 1;
            this.miSessionMarkBlue.Text = "&Blue\tCtrl+2";
            this.miSessionMarkBlue.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionMarkGold.Index = 2;
            this.miSessionMarkGold.Text = "Gol&d\tCtrl+3";
            this.miSessionMarkGold.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionMarkGreen.Index = 3;
            this.miSessionMarkGreen.Text = "&Green\tCtrl+4";
            this.miSessionMarkGreen.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionMarkOrange.Index = 4;
            this.miSessionMarkOrange.Text = "&Orange\tCtrl+5";
            this.miSessionMarkOrange.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionMarkPurple.Index = 5;
            this.miSessionMarkPurple.Text = "&Purple\tCtrl+6";
            this.miSessionMarkPurple.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miContextMarkSplit.Index = 6;
            this.miContextMarkSplit.Text = "-";
            this.miSessionMarkUnmark.Index = 7;
            this.miSessionMarkUnmark.Text = "&Unmark\tCtrl+0";
            this.miSessionMarkUnmark.Click += new EventHandler(this.miSessionMarkColor_Click);
            this.miSessionReplay.Index = 9;
            this.miSessionReplay.MenuItems.AddRange(new MenuItem[] { this.miSessionReissueRequests, this.miSessionReissueUnconditionally, this.miSessionReissueEdited, this.miSessionReissueComposer, this.miReissueSplit, this.miSessionReissueInIE });
            this.miSessionReplay.Text = "R&eplay";
            this.miSessionReissueRequests.Index = 0;
            this.miSessionReissueRequests.Text = "Reissue &Requests\tR";
            this.miSessionReissueRequests.Click += new EventHandler(this.miSessionReissueRequests_Click);
            this.miSessionReissueUnconditionally.Index = 1;
            this.miSessionReissueUnconditionally.Text = "Reissue &Unconditionally\tU";
            this.miSessionReissueUnconditionally.Click += new EventHandler(this.miSessionReissueUnconditionally_Click);
            this.miSessionReissueEdited.Index = 2;
            this.miSessionReissueEdited.Text = "Reissue and &Edit";
            this.miSessionReissueEdited.Click += new EventHandler(this.miSessionReissueEdited_Click);
            this.miSessionReissueComposer.Index = 3;
            this.miSessionReissueComposer.Text = "Reissue from &Composer";
            this.miSessionReissueComposer.Click += new EventHandler(this.miSessionReissueComposer_Click);
            this.miReissueSplit.Index = 4;
            this.miReissueSplit.Text = "-";
            this.miSessionReissueInIE.Index = 5;
            this.miSessionReissueInIE.Text = "Revisit in &IE";
            this.miSessionReissueInIE.Click += new EventHandler(this.miSessionReissueInIE_Click);
            this.miSessionSelect.Index = 10;
            this.miSessionSelect.MenuItems.AddRange(new MenuItem[] { this.miSessionSelectParent, this.miSessionSelectChildren, this.miSessionSelectDuplicates });
            this.miSessionSelect.Text = "Se&lect";
            this.miSessionSelectParent.Index = 0;
            this.miSessionSelectParent.Text = "&Parent Request\tP";
            this.miSessionSelectParent.Click += new EventHandler(this.miSessionSelectParent_Click);
            this.miSessionSelectChildren.Index = 1;
            this.miSessionSelectChildren.Text = "&Child Requests\tC";
            this.miSessionSelectChildren.Click += new EventHandler(this.miSessionSelectChildren_Click);
            this.miSessionSelectDuplicates.Index = 2;
            this.miSessionSelectDuplicates.Text = "&Duplicate Requests\tD";
            this.miSessionSelectDuplicates.Click += new EventHandler(this.miSessionSelectDuplicates_Click);
            this.miSessionWinDiff.Index = 11;
            this.miSessionWinDiff.Text = "C&ompare\tCtrl+W";
            this.miSessionWinDiff.Click += new EventHandler(this.miSessionWinDiff_Click);
            this.miSessionCOMETPeek.Index = 12;
            this.miSessionCOMETPeek.Text = "COMETPeek";
            this.miSessionCOMETPeek.Click += new EventHandler(this.miSessionCOMETPeek_Click);
            this.miSessionAbort.Index = 13;
            this.miSessionAbort.Text = "Abort Session";
            this.miSessionAbort.Click += new EventHandler(this.miSessionAbort_Click);
            this.miSessionReplayResponse.Index = 14;
            this.miSessionReplayResponse.Text = "C&lone Response";
            this.miSessionReplayResponse.Click += new EventHandler(this.miSessionReplayResponse_Click);
            this.miSessionUnlock.Index = 15;
            this.miSessionUnlock.Text = "Unloc&k For Editing\tF2";
            this.miSessionUnlock.Click += new EventHandler(this.miSessionUnlock_Click);
            this.miSessionSplit.Index = 0x10;
            this.miSessionSplit.Text = "-";
            this.miSessionInspectNewWindow.Index = 0x11;
            this.miSessionInspectNewWindow.Text = "Inspect in &New Window...\tShift+Enter";
            this.miSessionInspectNewWindow.Click += new EventHandler(this.miSessionInspectNewWindow_Click);
            this.miSessionProperties.Index = 0x12;
            this.miSessionProperties.Text = "&Properties...\tAlt+Enter";
            this.miSessionProperties.Click += new EventHandler(this.miSessionProperties_Click);
            this.imglSessionIcons.ImageStream = (ImageListStreamer)manager.GetObject("imglSessionIcons.ImageStream");
            this.imglSessionIcons.TransparentColor = System.Drawing.Color.Magenta;
            this.imglSessionIcons.Images.SetKeyName(0, "Send");
            this.imglSessionIcons.Images.SetKeyName(1, "SendBP");
            this.imglSessionIcons.Images.SetKeyName(2, "Receive");
            this.imglSessionIcons.Images.SetKeyName(3, "ReceiveBP");
            this.imglSessionIcons.Images.SetKeyName(4, "Doc");
            this.imglSessionIcons.Images.SetKeyName(5, "Image");
            this.imglSessionIcons.Images.SetKeyName(6, "Script");
            this.imglSessionIcons.Images.SetKeyName(7, "XML");
            this.imglSessionIcons.Images.SetKeyName(8, "HTML");
            this.imglSessionIcons.Images.SetKeyName(9, "CSS");
            this.imglSessionIcons.Images.SetKeyName(10, "Redir");
            this.imglSessionIcons.Images.SetKeyName(11, "Cache");
            this.imglSessionIcons.Images.SetKeyName(12, "Error");
            this.imglSessionIcons.Images.SetKeyName(13, "Secure");
            this.imglSessionIcons.Images.SetKeyName(14, "abort");
            this.imglSessionIcons.Images.SetKeyName(15, "Auth");
            this.imglSessionIcons.Images.SetKeyName(0x10, "HEAD");
            this.imglSessionIcons.Images.SetKeyName(0x11, "unchecked");
            this.imglSessionIcons.Images.SetKeyName(0x12, "checked");
            this.imglSessionIcons.Images.SetKeyName(0x13, "inspect");
            this.imglSessionIcons.Images.SetKeyName(20, "builder");
            this.imglSessionIcons.Images.SetKeyName(0x15, "timer");
            this.imglSessionIcons.Images.SetKeyName(0x16, "timeline");
            this.imglSessionIcons.Images.SetKeyName(0x17, "unlitbolt");
            this.imglSessionIcons.Images.SetKeyName(0x18, "bolt");
            this.imglSessionIcons.Images.SetKeyName(0x19, "filter");
            this.imglSessionIcons.Images.SetKeyName(0x1a, "browser");
            this.imglSessionIcons.Images.SetKeyName(0x1b, "movie");
            this.imglSessionIcons.Images.SetKeyName(0x1c, "audio");
            this.imglSessionIcons.Images.SetKeyName(0x1d, "font");
            this.imglSessionIcons.Images.SetKeyName(30, "flash");
            this.imglSessionIcons.Images.SetKeyName(0x1f, "silverlight");
            this.imglSessionIcons.Images.SetKeyName(0x20, "post");
            this.imglSessionIcons.Images.SetKeyName(0x21, "json");
            this.imglSessionIcons.Images.SetKeyName(0x22, "socket");
            this.imglSessionIcons.Images.SetKeyName(0x23, "compose");
            this.imglSessionIcons.Images.SetKeyName(0x24, "editunlocked");
            this.imglSessionIcons.Images.SetKeyName(0x25, "http206");
            this.imglSessionIcons.Images.SetKeyName(0x26, "SPDY");
            this.sbStatus.Location = new Point(0, 0x1a0);
            this.sbStatus.Name = "sbStatus";
            this.sbStatus.Panels.AddRange(new StatusBarPanel[] { this.sbpCapture, this.sbpProcessFilter, this.sbpBreakpoints, this.sbpSelCount, this.sbpInfo });
            this.sbStatus.ShowPanels = true;
            this.sbStatus.Size = new Size(0x3d8, 0x16);
            this.sbStatus.TabIndex = 0;
            this.sbStatus.PanelClick += new StatusBarPanelClickEventHandler(this.sbStatus_PanelClick);
            this.sbStatus.MouseMove += new MouseEventHandler(this.sbStatus_MouseMove);
            this.sbpCapture.AutoSize = StatusBarPanelAutoSize.Contents;
            this.sbpCapture.Icon = (Icon)manager.GetObject("sbpCapture.Icon");
            this.sbpCapture.MinWidth = 0x55;
            this.sbpCapture.Name = "sbpCapture";
            this.sbpCapture.Style = StatusBarPanelStyle.OwnerDraw;
            this.sbpCapture.Width = 0x55;
            this.sbpProcessFilter.AutoSize = StatusBarPanelAutoSize.Contents;
            this.sbpProcessFilter.MinWidth = 110;
            this.sbpProcessFilter.Name = "sbpProcessFilter";
            this.sbpProcessFilter.Text = "All Processes";
            this.sbpProcessFilter.Width = 110;
            this.sbpBreakpoints.Icon = (Icon)manager.GetObject("sbpBreakpoints.Icon");
            this.sbpBreakpoints.MinWidth = 0x16;
            this.sbpBreakpoints.Name = "sbpBreakpoints";
            this.sbpBreakpoints.Style = StatusBarPanelStyle.OwnerDraw;
            this.sbpBreakpoints.Width = 0x16;
            this.sbpSelCount.Alignment = HorizontalAlignment.Center;
            this.sbpSelCount.MinWidth = 50;
            this.sbpSelCount.Name = "sbpSelCount";
            this.sbpSelCount.ToolTipText = "Number of sessions";
            this.sbpSelCount.Width = 80;
            this.sbpInfo.BorderStyle = StatusBarPanelBorderStyle.None;
            this.sbpInfo.Name = "sbpInfo";
            this.sbpInfo.Width = 0x3e8;
            this.pnlSessions.BackColor = SystemColors.Control;
            this.pnlSessions.Controls.Add(this.lvSessions);
            this.pnlSessions.Controls.Add(this.btnSquish);
            this.pnlSessions.Controls.Add(this.lblSessions);
            this.pnlSessions.Controls.Add(this.txtExec);
            this.pnlSessions.Dock = DockStyle.Left;
            this.pnlSessions.Location = new Point(0, 0x1a);
            this.pnlSessions.Name = "pnlSessions";
            this.pnlSessions.Size = new Size(400, 390);
            this.pnlSessions.TabIndex = 1;
            this.lvSessions.Activation = ItemActivation.OneClick;
            this.lvSessions.AllowColumnReorder = true;
            this.lvSessions.AllowDrop = true;
            this.lvSessions.AutoArrange = false;
            this.lvSessions.BackColor = SystemColors.Window;
            this.lvSessions.BorderStyle = BorderStyle.FixedSingle;
            this.lvSessions.CausesValidation = false;
            this.lvSessions.Columns.AddRange(new ColumnHeader[] { this.colID, this.colStatus, this.colProtocol, this.colHost, this.colRequest, this.colResponseSize, this.colExpires, this.colContentType, this.colProcess, this.colComments, this.colCustom });
            this.lvSessions.ContextMenu = this.mnuSessionContext;
            this.lvSessions.Dock = DockStyle.Fill;
            this.lvSessions.Font = new Font("Tahoma", 8f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.lvSessions.FullRowSelect = true;
            this.lvSessions.HideSelection = false;
            this.lvSessions.LabelWrap = false;
            this.lvSessions.Location = new Point(0, 14);
            this.lvSessions.Name = "lvSessions";
            this.lvSessions.Size = new Size(400, 0x163);
            this.lvSessions.SmallImageList = this.imglSessionIcons;
            this.lvSessions.TabIndex = 1;
            this.lvSessions.UseCompatibleStateImageBehavior = false;
            this.lvSessions.View = View.Details;
            this.lvSessions.ItemShowProperties += new EventHandler(this.lvSessions_ItemShowProperties);
            this.lvSessions.ItemDrag += new ItemDragEventHandler(this.lvSessions_ItemDrag);
            this.lvSessions.SelectedIndexChanged += new EventHandler(this.lvSessions_SelectedIndexChanged);
            this.lvSessions.DragDrop += new DragEventHandler(this.lvSessions_DragDrop);
            this.lvSessions.DragEnter += new DragEventHandler(this.lvSessions_DragEnter);
            this.lvSessions.DoubleClick += new EventHandler(this.lvSessions_DoubleClick);
            this.lvSessions.KeyDown += new KeyEventHandler(this.lvSessions_KeyDown);
            this.lvSessions.KeyUp += new KeyEventHandler(this.lvSessions_KeyUp);
            this.colID.Text = "#";
            this.colID.Width = 0x2d;
            this.colStatus.Text = "Result";
            this.colStatus.TextAlign = HorizontalAlignment.Center;
            this.colStatus.Width = 50;
            this.colProtocol.Text = "Protocol";
            this.colProtocol.Width = 0x37;
            this.colHost.Text = "Host";
            this.colHost.TextAlign = HorizontalAlignment.Right;
            this.colHost.Width = 120;
            this.colRequest.Text = "URL";
            this.colRequest.Width = 150;
            this.colResponseSize.Text = "Body";
            this.colResponseSize.TextAlign = HorizontalAlignment.Right;
            this.colResponseSize.Width = 0x34;
            this.colExpires.Text = "Caching";
            this.colContentType.Text = "Content-Type";
            this.colContentType.Width = 80;
            this.colProcess.Text = "Process";
            this.colComments.Text = "Comments";
            this.colComments.Width = 80;
            this.colCustom.Text = "Custom";
            this.btnSquish.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnSquish.FlatStyle = FlatStyle.Popup;
            this.btnSquish.Font = new Font("Tahoma", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.btnSquish.Location = new Point(0x16c, 0);
            this.btnSquish.Name = "btnSquish";
            this.btnSquish.Size = new Size(0x24, 14);
            this.btnSquish.TabIndex = 3;
            this.btnSquish.TabStop = false;
            this.btnSquish.Text = "<<";
            this.btnSquish.Click += new EventHandler(this.btnSquish_Click);
            this.lblSessions.Dock = DockStyle.Top;
            this.lblSessions.Font = new Font("Tahoma", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            this.lblSessions.ForeColor = SystemColors.ControlDarkDark;
            this.lblSessions.Location = new Point(0, 0);
            this.lblSessions.Name = "lblSessions";
            this.lblSessions.Size = new Size(400, 14);
            this.lblSessions.TabIndex = 0;
            this.lblSessions.Text = "Web &Sessions";
            this.lblSessions.TextAlign = ContentAlignment.TopCenter;
            this.txtExec.AllowDrop = true;
            this.txtExec.AutoCompleteMode = AutoCompleteMode.Append;
            this.txtExec.AutoCompleteSource = AutoCompleteSource.CustomSource;
            this.txtExec.BackColor = System.Drawing.Color.Black;
            this.txtExec.CueText = "ALT+Q > type HELP...";
            this.txtExec.Dock = DockStyle.Bottom;
            this.txtExec.Font = new Font("Tahoma", 8.25f);
            this.txtExec.ForeColor = System.Drawing.Color.Lime;
            this.txtExec.Location = new Point(0, 0x171);
            this.txtExec.Name = "txtExec";
            this.txtExec.Size = new Size(400, 0x15);
            this.txtExec.TabIndex = 2;
            this.txtExec.TextChanged += new EventHandler(this.txtExec_TextChanged);
            this.txtExec.DragDrop += new DragEventHandler(this.txtExec_DragDrop);
            this.txtExec.DragOver += new DragEventHandler(this.txtExec_DragOver);
            this.txtExec.KeyUp += new KeyEventHandler(this.txtExec_KeyUp);
            this.splitterMain.BackColor = System.Drawing.Color.LightSlateGray;
            this.splitterMain.Location = new Point(400, 0x1a);
            this.splitterMain.Name = "splitterMain";
            this.splitterMain.Size = new Size(3, 390);
            this.splitterMain.TabIndex = 2;
            this.splitterMain.TabStop = false;
            this.splitterMain.DoubleClick += new EventHandler(this.splitterMain_DoubleClick);
            this.pnlInspector.BackColor = SystemColors.Control;
            this.pnlInspector.Controls.Add(this.tabsViews);
            this.pnlInspector.Dock = DockStyle.Fill;
            this.pnlInspector.Location = new Point(0x193, 0x1a);
            this.pnlInspector.Name = "pnlInspector";
            this.pnlInspector.Size = new Size(0x245, 390);
            this.pnlInspector.TabIndex = 3;
            this.tabsViews.AllowDrop = true;
            this.tabsViews.Controls.Add(this.pageStatistics);
            this.tabsViews.Controls.Add(this.pageInspector);
            this.tabsViews.Controls.Add(this.pageResponder);
            this.tabsViews.Controls.Add(this.pageBuilder);
            this.tabsViews.Dock = DockStyle.Fill;
            this.tabsViews.Font = new Font("Tahoma", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.tabsViews.HotTrack = true;
            this.tabsViews.ImageList = this.imglSessionIcons;
            this.tabsViews.Location = new Point(0, 0);
            this.tabsViews.Margin = new Padding(0);
            this.tabsViews.Multiline = true;
            this.tabsViews.Name = "tabsViews";
            this.tabsViews.SelectedIndex = 0;
            this.tabsViews.Size = new Size(0x245, 390);
            this.tabsViews.SizeMode = TabSizeMode.FillToRight;
            this.tabsViews.TabIndex = 0;
            this.tabsViews.SelectedIndexChanged += new EventHandler(this.tabsViews_SelectedIndexChanged);
            this.tabsViews.DragOver += new DragEventHandler(this.tabsViews_DragOver);
            this.tabsViews.MouseClick += new MouseEventHandler(this.tabsViews_MouseClick);
            this.pageStatistics.BackColor = System.Drawing.Color.Transparent;
            this.pageStatistics.ImageIndex = 0x15;
            this.pageStatistics.Location = new Point(4, 0x17);
            this.pageStatistics.Name = "pageStatistics";
            this.pageStatistics.Size = new Size(0x23d, 0x16b);
            this.pageStatistics.TabIndex = 1;
            this.pageStatistics.Text = "Statistics";
            this.pageStatistics.UseVisualStyleBackColor = true;
            this.pageInspector.Controls.Add(this.tabsResponse);
            this.pageInspector.Controls.Add(this.pnlInfoTip);
            this.pageInspector.Controls.Add(this.pnlSessionControls);
            this.pageInspector.Controls.Add(this.splitterInspector);
            this.pageInspector.Controls.Add(this.tabsRequest);
            this.pageInspector.Controls.Add(this.pnlInfoTipRequest);
            this.pageInspector.Controls.Add(this.pnlInfoBar);
            this.pageInspector.ImageIndex = 0x13;
            this.pageInspector.Location = new Point(4, 0x17);
            this.pageInspector.Name = "pageInspector";
            this.pageInspector.Size = new Size(0x23d, 0x16b);
            this.pageInspector.TabIndex = 0;
            this.pageInspector.Text = "Inspectors";
            this.pageInspector.UseVisualStyleBackColor = true;
            this.tabsResponse.AllowDrop = true;
            this.tabsResponse.Appearance = TabAppearance.FlatButtons;
            this.tabsResponse.ContextMenu = this.mnuInspectorsContext;
            this.tabsResponse.Dock = DockStyle.Fill;
            this.tabsResponse.HotTrack = true;
            this.tabsResponse.ImageList = this.imglSessionIcons;
            this.tabsResponse.ItemSize = new Size(0x2a, 0x12);
            this.tabsResponse.Location = new Point(0, 0x15b);
            this.tabsResponse.Margin = new Padding(0);
            this.tabsResponse.Multiline = true;
            this.tabsResponse.Name = "tabsResponse";
            this.tabsResponse.SelectedIndex = 0;
            this.tabsResponse.Size = new Size(0x23d, 0x10);
            this.tabsResponse.TabIndex = 5;
            this.tabsResponse.SelectedIndexChanged += new EventHandler(this.tabsResponse_SelectedIndexChanged);
            this.mnuInspectorsContext.MenuItems.AddRange(new MenuItem[] { this.miInspectorProperties, this.miInspectorHide });
            this.miInspectorProperties.Index = 0;
            this.miInspectorProperties.Text = "Inspector &Properties";
            this.miInspectorProperties.Click += new EventHandler(this.miInspectorProperties_Click);
            this.miInspectorHide.Index = 1;
            this.miInspectorHide.Text = "&Hide Inspector";
            this.miInspectorHide.Click += new EventHandler(this.miInspectorHide_Click);
            this.pnlInfoTip.BackColor = SystemColors.Info;
            this.pnlInfoTip.Controls.Add(this.btnDecodeResponse);
            this.pnlInfoTip.Dock = DockStyle.Top;
            this.pnlInfoTip.ForeColor = SystemColors.InfoText;
            this.pnlInfoTip.Location = new Point(0, 0x143);
            this.pnlInfoTip.Name = "pnlInfoTip";
            this.pnlInfoTip.Size = new Size(0x23d, 0x18);
            this.pnlInfoTip.TabIndex = 7;
            this.pnlInfoTip.Visible = false;
            this.btnDecodeResponse.Cursor = Cursors.Hand;
            this.btnDecodeResponse.Dock = DockStyle.Fill;
            this.btnDecodeResponse.FlatStyle = FlatStyle.Flat;
            this.btnDecodeResponse.Location = new Point(0, 0);
            this.btnDecodeResponse.Name = "btnDecodeResponse";
            this.btnDecodeResponse.Size = new Size(0x23d, 0x18);
            this.btnDecodeResponse.TabIndex = 1;
            this.btnDecodeResponse.Text = " Response is encoded and may need to be decoded before inspection. Click here to transform.";
            this.btnDecodeResponse.UseVisualStyleBackColor = true;
            this.btnDecodeResponse.Click += new EventHandler(this.btnDecodeResponse_Click);
            this.pnlSessionControls.BackColor = System.Drawing.Color.Red;
            this.pnlSessionControls.Controls.Add(this.cbxLoadFrom);
            this.pnlSessionControls.Controls.Add(this.lblBreakpoint);
            this.pnlSessionControls.Controls.Add(this.btnTamperSendClient);
            this.pnlSessionControls.Controls.Add(this.btnTamperSendServer);
            this.pnlSessionControls.Dock = DockStyle.Top;
            this.pnlSessionControls.ForeColor = SystemColors.WindowText;
            this.pnlSessionControls.Location = new Point(0, 0x12a);
            this.pnlSessionControls.Name = "pnlSessionControls";
            this.pnlSessionControls.Size = new Size(0x23d, 0x19);
            this.pnlSessionControls.TabIndex = 3;
            this.pnlSessionControls.Visible = false;
            this.cbxLoadFrom.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.cbxLoadFrom.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cbxLoadFrom.Location = new Point(410, 1);
            this.cbxLoadFrom.MaxDropDownItems = 20;
            this.cbxLoadFrom.Name = "cbxLoadFrom";
            this.cbxLoadFrom.Size = new Size(0x9e, 0x15);
            this.cbxLoadFrom.TabIndex = 5;
            this.cbxLoadFrom.SelectionChangeCommitted += new EventHandler(this.cbxLoadFrom_SelectionChangeCommitted);
            this.lblBreakpoint.Location = new Point(6, 5);
            this.lblBreakpoint.Name = "lblBreakpoint";
            this.lblBreakpoint.Size = new Size(0xa2, 14);
            this.lblBreakpoint.TabIndex = 4;
            this.lblBreakpoint.Text = "Breakpoint hit. Tamper, then:";
            this.btnTamperSendClient.BackColor = System.Drawing.Color.FromArgb(0x55, 0xd9, 6);
            this.btnTamperSendClient.ForeColor = System.Drawing.Color.Black;
            this.btnTamperSendClient.Location = new Point(0x128, 1);
            this.btnTamperSendClient.Name = "btnTamperSendClient";
            this.btnTamperSendClient.Size = new Size(0x70, 0x17);
            this.btnTamperSendClient.TabIndex = 2;
            this.btnTamperSendClient.Text = "Run to &Completion";
            this.btnTamperSendClient.UseVisualStyleBackColor = false;
            this.btnTamperSendClient.Click += new EventHandler(this.btnTamperSendClient_Click);
            this.btnTamperSendServer.BackColor = System.Drawing.Color.FromArgb(0xff, 0xff, 0x80);
            this.btnTamperSendServer.ForeColor = System.Drawing.Color.Black;
            this.btnTamperSendServer.Location = new Point(0xae, 1);
            this.btnTamperSendServer.Name = "btnTamperSendServer";
            this.btnTamperSendServer.Size = new Size(120, 0x17);
            this.btnTamperSendServer.TabIndex = 0;
            this.btnTamperSendServer.Text = "&Break on Response";
            this.btnTamperSendServer.UseVisualStyleBackColor = false;
            this.btnTamperSendServer.Click += new EventHandler(this.btnTamperSend_Click);
            this.splitterInspector.BackColor = System.Drawing.Color.LightSlateGray;
            this.splitterInspector.Dock = DockStyle.Top;
            this.splitterInspector.Location = new Point(0, 0x127);
            this.splitterInspector.Name = "splitterInspector";
            this.splitterInspector.Size = new Size(0x23d, 3);
            this.splitterInspector.TabIndex = 6;
            this.splitterInspector.TabStop = false;
            this.splitterInspector.DoubleClick += new EventHandler(this.splitterInspector_DoubleClick);
            this.tabsRequest.Appearance = TabAppearance.FlatButtons;
            this.tabsRequest.ContextMenu = this.mnuInspectorsContext;
            this.tabsRequest.Dock = DockStyle.Top;
            this.tabsRequest.HotTrack = true;
            this.tabsRequest.ImageList = this.imglSessionIcons;
            this.tabsRequest.ItemSize = new Size(0x2a, 0x12);
            this.tabsRequest.Location = new Point(0, 50);
            this.tabsRequest.Margin = new Padding(0);
            this.tabsRequest.Multiline = true;
            this.tabsRequest.Name = "tabsRequest";
            this.tabsRequest.SelectedIndex = 0;
            this.tabsRequest.Size = new Size(0x23d, 0xf5);
            this.tabsRequest.TabIndex = 4;
            this.tabsRequest.SelectedIndexChanged += new EventHandler(this.tabsRequest_SelectedIndexChanged);
            this.pnlInfoTipRequest.BackColor = SystemColors.Info;
            this.pnlInfoTipRequest.Controls.Add(this.btnDecodeRequest);
            this.pnlInfoTipRequest.Dock = DockStyle.Top;
            this.pnlInfoTipRequest.ForeColor = SystemColors.InfoText;
            this.pnlInfoTipRequest.Location = new Point(0, 0x1a);
            this.pnlInfoTipRequest.Name = "pnlInfoTipRequest";
            this.pnlInfoTipRequest.Size = new Size(0x23d, 0x18);
            this.pnlInfoTipRequest.TabIndex = 9;
            this.pnlInfoTipRequest.Visible = false;
            this.btnDecodeRequest.Cursor = Cursors.Hand;
            this.btnDecodeRequest.Dock = DockStyle.Fill;
            this.btnDecodeRequest.FlatStyle = FlatStyle.Flat;
            this.btnDecodeRequest.Location = new Point(0, 0);
            this.btnDecodeRequest.Name = "btnDecodeRequest";
            this.btnDecodeRequest.Size = new Size(0x23d, 0x18);
            this.btnDecodeRequest.TabIndex = 1;
            this.btnDecodeRequest.Text = " Request is encoded and may need to be decoded before inspection. Click here to transform.";
            this.btnDecodeRequest.UseVisualStyleBackColor = true;
            this.btnDecodeRequest.Click += new EventHandler(this.btnDecodeRequest_Click);
            this.pnlInfoBar.BackColor = System.Drawing.Color.Yellow;
            this.pnlInfoBar.Controls.Add(this.btnPromptHTTPS);
            this.pnlInfoBar.Dock = DockStyle.Top;
            this.pnlInfoBar.ForeColor = System.Drawing.Color.Black;
            this.pnlInfoBar.Location = new Point(0, 0);
            this.pnlInfoBar.Name = "pnlInfoBar";
            this.pnlInfoBar.Size = new Size(0x23d, 0x1a);
            this.pnlInfoBar.TabIndex = 10;
            this.pnlInfoBar.Visible = false;
            this.btnPromptHTTPS.Cursor = Cursors.Hand;
            this.btnPromptHTTPS.Dock = DockStyle.Fill;
            this.btnPromptHTTPS.FlatStyle = FlatStyle.Flat;
            this.btnPromptHTTPS.ImageAlign = ContentAlignment.BottomRight;
            this.btnPromptHTTPS.ImageIndex = 12;
            this.btnPromptHTTPS.ImageList = this.imglSessionIcons;
            this.btnPromptHTTPS.Location = new Point(0, 0);
            this.btnPromptHTTPS.Name = "btnPromptHTTPS";
            this.btnPromptHTTPS.Size = new Size(0x23d, 0x1a);
            this.btnPromptHTTPS.TabIndex = 4;
            this.btnPromptHTTPS.Text = " HTTPS decryption is disabled. Click to configure...";
            this.btnPromptHTTPS.TextAlign = ContentAlignment.BottomCenter;
            this.btnPromptHTTPS.TextImageRelation = TextImageRelation.ImageBeforeText;
            this.btnPromptHTTPS.UseVisualStyleBackColor = true;
            this.btnPromptHTTPS.Click += new EventHandler(this.btnPromptHTTPS_Click);
            this.pageResponder.ImageIndex = 0x17;
            this.pageResponder.Location = new Point(4, 0x17);
            this.pageResponder.Name = "pageResponder";
            this.pageResponder.Size = new Size(0x23d, 0x16b);
            this.pageResponder.TabIndex = 5;
            this.pageResponder.Text = "AutoResponder";
            this.pageResponder.UseVisualStyleBackColor = true;
            this.pageBuilder.AllowDrop = true;
            this.pageBuilder.ImageIndex = 0x23;
            this.pageBuilder.Location = new Point(4, 0x17);
            this.pageBuilder.Name = "pageBuilder";
            this.pageBuilder.Size = new Size(0x23d, 0x16b);
            this.pageBuilder.TabIndex = 4;
            this.pageBuilder.Text = "Composer";
            this.pageBuilder.UseVisualStyleBackColor = true;
            this.dlgSaveBinary.AddExtension = false;
            this.dlgSaveBinary.Filter = "All files (*.*)|*.*";
            this.dlgSaveBinary.Title = "Save as...";
            this.notifyIcon.ContextMenuStrip = this.mnuNotify;
            this.notifyIcon.Icon = (Icon)manager.GetObject("notifyIcon.Icon");
            this.notifyIcon.Text = "Fiddler";
            this.notifyIcon.MouseClick += new MouseEventHandler(this.notifyIcon_MouseClick);
            this.mnuNotify.Items.AddRange(new ToolStripItem[] { this.miNotifyRestore, this.miNotifyCapturing, this.toolStripMenuItem1, this.miNotifyExit });
            this.mnuNotify.Name = "mnuNotify";
            this.mnuNotify.Size = new Size(0x9a, 0x4c);
            this.miNotifyRestore.Name = "miNotifyRestore";
            this.miNotifyRestore.Size = new Size(0x99, 0x16);
            this.miNotifyRestore.Text = "&Restore Fiddler";
            this.miNotifyRestore.Click += new EventHandler(this.miNotifyRestore_Click);
            this.miNotifyCapturing.CheckOnClick = true;
            this.miNotifyCapturing.Name = "miNotifyCapturing";
            this.miNotifyCapturing.Size = new Size(0x99, 0x16);
            this.miNotifyCapturing.Text = "&Capture Traffic";
            this.miNotifyCapturing.Click += new EventHandler(this.miNotifyCapture_Click);
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new Size(150, 6);
            this.miNotifyExit.Name = "miNotifyExit";
            this.miNotifyExit.Size = new Size(0x99, 0x16);
            this.miNotifyExit.Text = "E&xit";
            this.miNotifyExit.Click += new EventHandler(this.miNotifyExit_Click);
            this.dlgSaveZip.DefaultExt = "zip";
            this.dlgSaveZip.Filter = "Session Archive (*.saz)|*.saz|Password-Protected SAZ (*.saz)|*.saz";
            this.dlgSaveZip.Title = "Save Session Archive to...";
            this.dlgLoadZip.DefaultExt = "saz";
            this.dlgLoadZip.Filter = "Session Archive (*.saz)|*.saz|All files|*.*";
            this.dlgLoadZip.Multiselect = true;
            this.dlgLoadZip.Title = "Load Session Archives";
            this.imglToolbar.ImageStream = (ImageListStreamer)manager.GetObject("imglToolbar.ImageStream");
            this.imglToolbar.TransparentColor = System.Drawing.Color.Magenta;
            this.imglToolbar.Images.SetKeyName(0, "textplain");
            this.imglToolbar.Images.SetKeyName(1, "image");
            this.imglToolbar.Images.SetKeyName(2, "script");
            this.imglToolbar.Images.SetKeyName(3, "xml");
            this.imglToolbar.Images.SetKeyName(4, "html");
            this.imglToolbar.Images.SetKeyName(5, "css");
            this.imglToolbar.Images.SetKeyName(6, "redirect");
            this.imglToolbar.Images.SetKeyName(7, "cached");
            this.imglToolbar.Images.SetKeyName(8, "redbang");
            this.imglToolbar.Images.SetKeyName(9, "lock");
            this.imglToolbar.Images.SetKeyName(10, "noentry");
            this.imglToolbar.Images.SetKeyName(11, "key");
            this.imglToolbar.Images.SetKeyName(12, "info");
            this.imglToolbar.Images.SetKeyName(13, "unchecked");
            this.imglToolbar.Images.SetKeyName(14, "checked");
            this.imglToolbar.Images.SetKeyName(15, "inspect");
            this.imglToolbar.Images.SetKeyName(0x10, "builder");
            this.imglToolbar.Images.SetKeyName(0x11, "timer");
            this.imglToolbar.Images.SetKeyName(0x12, "timeline");
            this.imglToolbar.Images.SetKeyName(0x13, "darkbolt");
            this.imglToolbar.Images.SetKeyName(20, "litbolt");
            this.imglToolbar.Images.SetKeyName(0x15, "filter");
            this.imglToolbar.Images.SetKeyName(0x16, "ie");
            this.imglToolbar.Images.SetKeyName(0x17, "back");
            this.imglToolbar.Images.SetKeyName(0x18, "copy");
            this.imglToolbar.Images.SetKeyName(0x19, "find");
            this.imglToolbar.Images.SetKeyName(0x1a, "help");
            this.imglToolbar.Images.SetKeyName(0x1b, "comment");
            this.imglToolbar.Images.SetKeyName(0x1c, "refresh");
            this.imglToolbar.Images.SetKeyName(0x1d, "remove");
            this.imglToolbar.Images.SetKeyName(30, "tools");
            this.imglToolbar.Images.SetKeyName(0x1f, "resume");
            this.imglToolbar.Images.SetKeyName(0x20, "save");
            this.imglToolbar.Images.SetKeyName(0x21, "mark");
            this.imglToolbar.Images.SetKeyName(0x22, "close");
            this.imglToolbar.Images.SetKeyName(0x23, "tearoff");
            this.imglToolbar.Images.SetKeyName(0x24, "streaming");
            this.imglToolbar.Images.SetKeyName(0x25, "clearcache");
            this.imglToolbar.Images.SetKeyName(0x26, "connected");
            this.imglToolbar.Images.SetKeyName(0x27, "notconnected");
            this.imglToolbar.Images.SetKeyName(40, "decoder");
            this.imglToolbar.Images.SetKeyName(0x29, "crosshair");
            this.imglToolbar.Images.SetKeyName(0x2a, "camera");
            this.imglToolbar.Images.SetKeyName(0x2b, "Win8");
            this.pnlTopNotice.BackColor = System.Drawing.Color.Yellow;
            this.pnlTopNotice.Controls.Add(this.btnWarnDetached);
            this.pnlTopNotice.Dock = DockStyle.Top;
            this.pnlTopNotice.ForeColor = System.Drawing.Color.Black;
            this.pnlTopNotice.Location = new Point(0, 0);
            this.pnlTopNotice.Name = "pnlTopNotice";
            this.pnlTopNotice.Size = new Size(0x3d8, 0x1a);
            this.pnlTopNotice.TabIndex = 11;
            this.pnlTopNotice.Visible = false;
            this.btnWarnDetached.Cursor = Cursors.Hand;
            this.btnWarnDetached.Dock = DockStyle.Fill;
            this.btnWarnDetached.FlatStyle = FlatStyle.Flat;
            this.btnWarnDetached.ImageAlign = ContentAlignment.BottomRight;
            this.btnWarnDetached.ImageIndex = 12;
            this.btnWarnDetached.ImageList = this.imglSessionIcons;
            this.btnWarnDetached.Location = new Point(0, 0);
            this.btnWarnDetached.Name = "btnWarnDetached";
            this.btnWarnDetached.Size = new Size(0x3d8, 0x1a);
            this.btnWarnDetached.TabIndex = 4;
            this.btnWarnDetached.Text = "The system proxy was changed. Click to reenable Fiddler capture.";
            this.btnWarnDetached.TextAlign = ContentAlignment.BottomCenter;
            this.btnWarnDetached.TextImageRelation = TextImageRelation.ImageBeforeText;
            this.btnWarnDetached.UseVisualStyleBackColor = true;
            this.btnWarnDetached.Click += new EventHandler(this.btnWarnDetached_Click);
            this.AutoScaleBaseSize = new Size(5, 14);
            this.BackColor = SystemColors.AppWorkspace;
            base.ClientSize = new Size(0x3d8, 0x1b6);
            base.Controls.Add(this.pnlInspector);
            base.Controls.Add(this.splitterMain);
            base.Controls.Add(this.pnlSessions);
            base.Controls.Add(this.sbStatus);
            base.Controls.Add(this.pnlTopNotice);
            this.Font = new Font("Tahoma", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            base.Icon = (Icon)manager.GetObject("$this.Icon");
            base.KeyPreview = true;
            base.Menu = this.mnuMain;
            base.Name = "frmViewer";
            this.Text = "Fiddler Web Debugger";
            base.Closing += new CancelEventHandler(this.frmViewer_Closing);
            base.Load += new EventHandler(this.frmViewer_Load);
            base.KeyDown += new KeyEventHandler(this.frmViewer_KeyDown);
            this.sbpCapture.EndInit();
            this.sbpProcessFilter.EndInit();
            this.sbpBreakpoints.EndInit();
            this.sbpSelCount.EndInit();
            this.sbpInfo.EndInit();
            this.pnlSessions.ResumeLayout(false);
            this.pnlSessions.PerformLayout();
            this.pnlInspector.ResumeLayout(false);
            this.tabsViews.ResumeLayout(false);
            this.pageInspector.ResumeLayout(false);
            this.pnlInfoTip.ResumeLayout(false);
            this.pnlSessionControls.ResumeLayout(false);
            this.pnlInfoTipRequest.ResumeLayout(false);
            this.pnlInfoBar.ResumeLayout(false);
            this.mnuNotify.ResumeLayout(false);
            this.pnlTopNotice.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void lvSessions_DoubleClick(object sender, EventArgs e)
        {
            this.actInspectSession();
        }

        private void lvSessions_DragDrop(object sender, DragEventArgs e)
        {
            Session[] sessionArray;
            Session[] sessionArray2;
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] data = (string[])e.Data.GetData("FileDrop", false);
                foreach (string str in data)
                {
                    if (Directory.Exists(str))
                    {
                        this.CreateSessionsForFolder(str);
                    }
                    else
                    {
                        this.CreateSessionsForFile(str, string.Empty);
                    }
                }
                e.Effect = DragDropEffects.Copy;
                return;
            }
            if (!e.Data.GetDataPresent("Fiddler.Session[]"))
            {
                e.Effect = DragDropEffects.None;
                return;
            }
            try
            {
                sessionArray = (Session[])e.Data.GetData("Fiddler.Session[]");
            }
            catch (InvalidCastException exception)
            {
                if (e.Data.GetDataPresent("Fiddler.SessionData[]"))
                {
                    try
                    {
                        object[] objArray = (object[])e.Data.GetData("Fiddler.SessionData[]");
                        sessionArray = new Session[objArray.Length];
                        for (int j = 0; j < objArray.Length; j++)
                        {
                            sessionArray[j] = new Session(((SessionData)objArray[j]).oRequest, ((SessionData)objArray[j]).oResponse);
                            sessionArray[j].LoadMetadata(new MemoryStream(((SessionData)objArray[j]).oMetadata));
                        }
                        goto Label_016C;
                    }
                    catch (Exception exception2)
                    {
                        MessageBox.Show(exception2.Message, "Drag/drop failure");
                        return;
                    }
                }
                FiddlerApplication.DoNotifyUser("Fiddler is unable to accept drops from other processes.\n\n" + exception.Message, "Operation failed");
                return;
            }
            catch
            {
                return;
            }
        Label_016C:
            sessionArray2 = sessionArray;
            for (int i = 0; i < sessionArray2.Length; i++)
            {
                Session session = sessionArray2[i];
                try
                {
                    MemoryStream oFS = new MemoryStream();
                    MemoryStream stream2 = new MemoryStream();
                    MemoryStream strmMetadata = new MemoryStream();
                    session.WriteRequestToStream(false, true, oFS);
                    session.WriteResponseToStream(stream2, false);
                    session.WriteMetadataToStream(strmMetadata);
                    if (strmMetadata.Length < 1L)
                    {
                        strmMetadata = null;
                    }
                    else
                    {
                        strmMetadata.Position = 0L;
                    }
                    this.AddReportedSession(oFS.ToArray(), stream2.ToArray(), strmMetadata);
                }
                catch (Exception exception3)
                {
                    FiddlerApplication.ReportException(exception3);
                }
            }
        }

        private void lvSessions_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Link | DragDropEffects.Copy;
            }
            else if (e.Data.GetDataPresent("Fiddler.Session[]"))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void lvSessions_ItemDrag(object sender, ItemDragEventArgs e)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length > 0)
            {
                SessionData[] data = new SessionData[selectedSessions.Length];
                for (int i = 0; i < selectedSessions.Length; i++)
                {
                    data[i] = new SessionData(selectedSessions[i]);
                }
                DataObject obj2 = new DataObject();
                obj2.SetData(selectedSessions);
                obj2.SetData(data);
                this.lvSessions.AllowDrop = false;
                this.lvSessions.DoDragDrop(obj2, DragDropEffects.Copy);
                this.lvSessions.AllowDrop = true;
            }
        }

        private void lvSessions_ItemShowProperties(object sender, EventArgs e)
        {
            this.actViewSessionProperties();
        }

        private void lvSessions_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Return)
            {
                e.Handled = e.SuppressKeyPress = true;
                if (this.lvSessions.SelectedCount > 1)
                {
                    Utilities.activateTabByTitle("Statistics", this.tabsViews);
                }
                else
                {
                    this.actInspectSession();
                }
            }
            if (e.Modifiers == (Keys.Control | Keys.Shift))
            {
                switch (e.KeyCode)
                {
                    case Keys.S:
                        e.Handled = e.SuppressKeyPress = true;
                        this.miSessionCopyEntire_Click(null, null);
                        break;

                    case Keys.T:
                        e.Handled = e.SuppressKeyPress = true;
                        this.miSessionCopyHeadlines_Click(null, null);
                        break;

                    case Keys.C:
                        e.Handled = e.SuppressKeyPress = true;
                        this.miSessionCopyHeaders_Click(null, null);
                        break;
                }
            }
            if (e.Modifiers != Keys.Control)
            {
                if (e.Modifiers == Keys.Shift)
                {
                    switch (e.KeyCode)
                    {
                        case Keys.Return:
                            e.Handled = e.SuppressKeyPress = true;
                            this.actInspectInNewWindow();
                            return;

                        case Keys.Delete:
                            e.Handled = e.SuppressKeyPress = true;
                            this.miSessionRemoveUnselected_Click(null, null);
                            return;
                    }
                }
                if (e.Modifiers == Keys.Alt)
                {
                    switch (e.KeyCode)
                    {
                        case Keys.D1:
                            this.actSelectMarkedSessions("Red");
                            e.Handled = e.SuppressKeyPress = true;
                            break;

                        case Keys.D2:
                            this.actSelectMarkedSessions("Blue");
                            e.Handled = e.SuppressKeyPress = true;
                            break;

                        case Keys.D3:
                            this.actSelectMarkedSessions("Gold");
                            e.Handled = e.SuppressKeyPress = true;
                            break;

                        case Keys.D4:
                            this.actSelectMarkedSessions("Green");
                            e.Handled = e.SuppressKeyPress = true;
                            break;

                        case Keys.D5:
                            this.actSelectMarkedSessions("Orange");
                            e.Handled = e.SuppressKeyPress = true;
                            break;

                        case Keys.D6:
                            this.actSelectMarkedSessions("Purple");
                            e.Handled = e.SuppressKeyPress = true;
                            break;
                    }
                }
                if (((e.KeyCode == Keys.R) || (e.KeyCode == Keys.U)) && ((e.Modifiers == Keys.None) || (e.Modifiers == Keys.Shift)))
                {
                    Keys keyCode = e.KeyCode;
                    if (keyCode != Keys.R)
                    {
                        if (keyCode != Keys.U)
                        {
                            return;
                        }
                    }
                    else
                    {
                        e.SuppressKeyPress = e.Handled = true;
                        this.miSessionReissueRequests_Click(null, null);
                        return;
                    }
                    e.SuppressKeyPress = e.Handled = true;
                    this.miSessionReissueUnconditionally_Click(null, null);
                }
                else if (e.Modifiers == Keys.None)
                {
                    Keys keys6 = e.KeyCode;
                    if (keys6 <= Keys.Delete)
                    {
                        switch (keys6)
                        {
                            case Keys.Escape:
                                e.Handled = e.SuppressKeyPress = true;
                                FiddlerApplication.SuppressReportUpdates = true;
                                this.lvSessions.SelectedItems.Clear();
                                FiddlerApplication.SuppressReportUpdates = false;
                                break;

                            case Keys.Space:
                                if (this.lvSessions.SelectedCount > 0)
                                {
                                    this.lvSessions.SelectedItems[0].EnsureVisible();
                                    e.Handled = e.SuppressKeyPress = true;
                                }
                                break;

                            case Keys.Delete:
                                e.Handled = e.SuppressKeyPress = true;
                                this.miSessionRemoveSelected_Click(null, null);
                                break;
                        }
                    }
                    else
                    {
                        switch (keys6)
                        {
                            case Keys.C:
                                e.Handled = e.SuppressKeyPress = true;
                                this.miSessionSelectChildren_Click(null, null);
                                return;

                            case Keys.D:
                                e.Handled = e.SuppressKeyPress = true;
                                this.miSessionSelectDuplicates_Click(null, null);
                                return;

                            case Keys.M:
                                e.Handled = e.SuppressKeyPress = true;
                                this.actCommentSelectedSessions();
                                break;

                            case Keys.P:
                                e.Handled = e.SuppressKeyPress = true;
                                this.miSessionSelectParent_Click(null, null);
                                return;

                            default:
                                return;
                        }
                    }
                }
            }
            else
            {
                bool flag = true;
                switch (e.KeyCode)
                {
                    case Keys.U:
                        this.miSessionCopyURL_Click(null, null);
                        break;

                    case Keys.W:
                        this.miSessionWinDiff_Click(null, null);
                        break;

                    case Keys.X:
                        this.miSessionRemoveAll_Click(null, null);
                        break;

                    case Keys.I:
                        this.actInvertSelectedSessions();
                        break;

                    case Keys.D0:
                        this.miSessionMarkColor_Click(this.miSessionMarkUnmark, null);
                        break;

                    case Keys.D1:
                        this.miSessionMarkColor_Click(this.miSessionMarkRed, null);
                        break;

                    case Keys.D2:
                        this.miSessionMarkColor_Click(this.miSessionMarkBlue, null);
                        break;

                    case Keys.D3:
                        this.miSessionMarkColor_Click(this.miSessionMarkGold, null);
                        break;

                    case Keys.D4:
                        this.miSessionMarkColor_Click(this.miSessionMarkGreen, null);
                        break;

                    case Keys.D5:
                        this.miSessionMarkColor_Click(this.miSessionMarkOrange, null);
                        break;

                    case Keys.D6:
                        this.miSessionMarkColor_Click(this.miSessionMarkPurple, null);
                        break;

                    case Keys.A:
                        this.actSelectAll();
                        break;

                    case Keys.C:
                        this.miSessionCopySummary_Click(null, null);
                        break;

                    default:
                        flag = false;
                        break;
                }
                if (flag)
                {
                    e.SuppressKeyPress = e.Handled = true;
                }
            }
        }

        private void lvSessions_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Modifiers == Keys.None)
            {
                Keys keyCode = e.KeyCode;
                switch (keyCode)
                {
                    case Keys.Back:
                        e.SuppressKeyPress = e.Handled = true;
                        this.lvSessions.ActivatePreviousItem();
                        return;

                    case Keys.Insert:
                        e.SuppressKeyPress = e.Handled = true;
                        if ((this.lvSessions.SelectedCount == 1) && (this.GetFirstSelectedSession().oFlags["ui-bold"] == "user-marked"))
                        {
                            this.miSessionMarkColor_Click(this.miSessionMarkUnmark, EventArgs.Empty);
                            return;
                        }
                        this.miSessionMarkColor_Click(this.miSessionMarkRed, EventArgs.Empty);
                        break;

                    default:
                        if (keyCode == Keys.F2)
                        {
                            e.SuppressKeyPress = e.Handled = true;
                            this.miSessionUnlock_Click(null, null);
                        }
                        return;
                }
            }
        }

        private void lvSessions_OnSessionsAdded()
        {
            this.UpdateStatusBar(true);
        }

        private void lvSessions_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!FiddlerApplication.isClosing)
            {
                this.lvSessions.StoreActiveItem();
                this.actRefreshUI();
            }
        }

        [STAThread]
        private static void Main(string[] arrArgs)
        {
            Application.EnableVisualStyles();
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(frmViewer.UnhandledExceptionHandler);
            RunMain(arrArgs);
        }

        private void miBreakAtChoice_Check(object sender, EventArgs e)
        {
            MenuItem item = sender as MenuItem;
            if (item != null)
            {
                this.miRulesBreakAtNothing.Checked = false;
                this.miRulesBreakAtRequest.Checked = false;
                this.miRulesBreakAtResponse.Checked = false;
                item.Checked = true;
                this._UpdateBreakpointMenu();
            }
        }

        private void miCaptureEnabled_Click(object sender, EventArgs e)
        {
            this.actToggleCapture();
        }

        private void miCaptureRules_Click(object sender, EventArgs e)
        {
            try
            {
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.script.delaycreate", true) && !System.IO.File.Exists(CONFIG.GetPath("CustomRules")))
                {
                    FiddlerApplication.Log.LogFormat("Generating user's script file; copying '{0}' to '{1}'.", new object[] { CONFIG.GetPath("SampleRules"), CONFIG.GetPath("CustomRules") });
                    System.IO.File.Copy(CONFIG.GetPath("SampleRules"), CONFIG.GetPath("CustomRules"));
                }
                string arguments = "\"" + CONFIG.GetPath("CustomRules") + "\"";
                using (Process.Start(CONFIG.JSEditor, arguments))
                {
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Failed to launch script editor for CustomRules.js\nJSEditor: " + CONFIG.JSEditor + "\n\n" + exception.Message + "\nPlease see Help for information on setting the JSEditor.", "Editor Cannot Start");
            }
        }

        private void miContextSaveAndOpenBody_Click(object sender, EventArgs e)
        {
            this.actSaveAndOpenResponseBodies();
        }

        private void miEditPaste_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsFileDropList())
            {
                this.actPasteFilesFromClipboard();
            }
            else if (Clipboard.ContainsImage())
            {
                this.actPasteImageFromClipboard();
            }
            else
            {
                this.actPasteDataURIFromClipboard();
            }
        }

        private void miEditSelectAll_Click(object sender, EventArgs e)
        {
            this.actSelectAll();
        }

        private void miEditUnlock_Click(object sender, EventArgs e)
        {
            this.actToggleSessionUnlock();
        }

        private void miExit_Click(object sender, EventArgs e)
        {
            this.actExit();
        }

        private void miFileLoad_Click(object sender, EventArgs e)
        {
            if (this.dlgLoadZip.ShowDialog(this) == DialogResult.OK)
            {
                foreach (string str in this.dlgLoadZip.FileNames)
                {
                    this.actLoadSessionArchive(str);
                }
            }
        }

        private void miFileMinimizeToTray_Click(object sender, EventArgs e)
        {
            this.actMinimizeToTray();
        }

        private void miFileMRUClear_Click(object sender, EventArgs e)
        {
            this.oSAZMRU.PurgeAll();
        }

        private void miFileMRUPrune_Click(object sender, EventArgs e)
        {
            this.oSAZMRU.PruneObsolete();
        }

        private void miFileNew_Click(object sender, EventArgs e)
        {
            Utilities.RunExecutable(Assembly.GetExecutingAssembly().Location, "-viewer");
        }

        private void miFileSaveAllSessions_Click(object sender, EventArgs e)
        {
            this.actSaveAllSessions();
        }

        private void miFileSaveAndOpenBody_Click(object sender, EventArgs e)
        {
            this.actSaveAndOpenResponseBodies();
        }

        private void miHelpAbout_Click(object sender, EventArgs e)
        {
            frmAbout.DoAboutBox();
        }

        private void miHelpCommunity_Click(object sender, EventArgs e)
        {
            Utilities.LaunchHyperlink(CONFIG.GetUrl("REDIR") + "FIDDLERDISC");
        }

        private void miHelpContents_Click(object sender, EventArgs e)
        {
            this.actGetHelp();
        }

        private void miHelpHTTP_Click(object sender, EventArgs e)
        {
            Utilities.LaunchHyperlink(CONFIG.GetUrl("REDIR") + "HTTPREFERENCE");
        }

        private void miHelpShowFiltered_Click(object sender, EventArgs e)
        {
            this.miHelpShowFiltered.Checked = !this.miHelpShowFiltered.Checked;
            if (this.miHelpShowFiltered.Checked && (DialogResult.Cancel == MessageBox.Show("Filter troubleshooting is now enabled.\n\nFiddler will show all sessions that Filters would otherwise hide, using a 'strikethrough' font. The Comments column for each filtered session will show which Filter was responsible for hiding the traffic to allow you to adjust your filters accordingly.\n\nFor more information, see http://fiddler2.com/r/?filters", "Troubleshoot Filters", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)))
            {
                this.miHelpShowFiltered.Checked = false;
            }
            FiddlerApplication.Prefs.SetBoolPref("fiddler.filters.ephemeral.debugmode", this.miHelpShowFiltered.Checked);
        }

        private void miHelpUpdates_Click(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(this.actCheckForUpdatesVerbose));
            thread.IsBackground = true;
            thread.Start();
        }

        private void miInspectorHide_Click(object sender, EventArgs e)
        {
            if ((this.mnuInspectorsContext.SourceControl != null) && (this.mnuInspectorsContext.SourceControl is TabControl))
            {
                TabPage selectedTab = ((TabControl)this.mnuInspectorsContext.SourceControl).SelectedTab;
                if ((selectedTab != null) && (selectedTab.Tag != null))
                {
                    string fullName = ((Inspector2)selectedTab.Tag).GetType().FullName;
                    if (DialogResult.Yes == MessageBox.Show(string.Format("Are you sure you want to permanently remove the {0} inspector?\n\n(To restore it later, use about:config)", fullName), "Confirm Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
                    {
                        FiddlerApplication.Prefs.SetStringPref("fiddler.inspectors.hidelist", FiddlerApplication.Prefs.GetStringPref("fiddler.inspectors.hidelist", string.Empty) + ";" + fullName);
                        ((TabControl)this.mnuInspectorsContext.SourceControl).TabPages.Remove(selectedTab);
                    }
                }
            }
        }

        private void miInspectorProperties_Click(object sender, EventArgs e)
        {
            if ((this.mnuInspectorsContext.SourceControl != null) && (this.mnuInspectorsContext.SourceControl is TabControl))
            {
                TabPage selectedTab = ((TabControl)this.mnuInspectorsContext.SourceControl).SelectedTab;
                if ((selectedTab != null) && (selectedTab.Tag != null))
                {
                    ((Inspector2)selectedTab.Tag).ShowAboutBox();
                }
            }
        }

        private void miManipulateGZIP_Click(object sender, EventArgs e)
        {
            this.miManipulateGZIP.Checked = !this.miManipulateGZIP.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.forcegzip", this.miManipulateGZIP.Checked);
        }

        private void miManipulateIgnoreImages_Click(object sender, EventArgs e)
        {
            this.miManipulateIgnoreImages.Checked = !this.miManipulateIgnoreImages.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.rules.hideimages", this.miManipulateIgnoreImages.Checked);
        }

        private void miManipulateRequireProxyAuth_Click(object sender, EventArgs e)
        {
            this.miManipulateRequireProxyAuth.Checked = !this.miManipulateRequireProxyAuth.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.ephemeral.rules.requireproxyauth", this.miManipulateRequireProxyAuth.Checked);
        }

        private void miNotifyCapture_Click(object sender, EventArgs e)
        {
            this.actToggleCapture();
        }

        private void miNotifyExit_Click(object sender, EventArgs e)
        {
            this.actExit();
        }

        private void miNotifyRestore_Click(object sender, EventArgs e)
        {
            this.actRestoreWindow();
        }

        private void miReportBug_Click(object sender, EventArgs e)
        {
            try
            {
                using (Process.Start("mailto:fiddler@telerik.com?Subject=Fiddler%20" + Application.ProductVersion))
                {
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Looks like you don't have a mailto: handler installed.\nJust send an email to fiddler@telerik.com\n" + exception.Message, "Oops");
            }
        }

        private void miRulesBreakpointsIgnoreImages_Click(object sender, EventArgs e)
        {
            this.miRulesBreakpointsIgnoreImages.Checked = !this.miRulesBreakpointsIgnoreImages.Checked;
            CONFIG.bBreakOnImages = !this.miRulesBreakpointsIgnoreImages.Checked;
        }

        private void miRulesIgnoreConnects_Click(object sender, EventArgs e)
        {
            this.miRulesIgnoreConnects.Checked = !this.miRulesIgnoreConnects.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.rules.hideconnects", this.miRulesIgnoreConnects.Checked);
        }

        private void miRulesRemoveEncoding_Click(object sender, EventArgs e)
        {
            this.miRulesRemoveEncoding.Checked = !this.miRulesRemoveEncoding.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.rules.removeencoding", this.miRulesRemoveEncoding.Checked);
        }

        private void miSessionAbort_Click(object sender, EventArgs e)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length >= 1)
            {
                foreach (Session session in selectedSessions)
                {
                    session.Abort();
                }
            }
        }

        private void miSessionAddComment_Click(object sender, EventArgs e)
        {
            this.actCommentSelectedSessions();
        }

        private void miSessionCOMETPeek_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                firstSelectedSession.COMETPeek();
                FiddlerApplication.UI.actRefreshUI();
            }
        }

        private void miSessionCopyColumn_Click(object sender, EventArgs e)
        {
            try
            {
                ListView.SelectedListViewItemCollection selectedItems = this.lvSessions.SelectedItems;
                if (selectedItems.Count >= 1)
                {
                    int subItemIndexFromPoint = this.lvSessions.GetSubItemIndexFromPoint(this.lvSessions.PointToClient(this._ptContextPopup));
                    if (subItemIndexFromPoint >= 0)
                    {
                        StringBuilder builder = new StringBuilder(0x200);
                        foreach (ListViewItem item in selectedItems)
                        {
                            string str = (item.SubItems.Count > subItemIndexFromPoint) ? item.SubItems[subItemIndexFromPoint].Text : string.Empty;
                            builder.AppendLine(str);
                        }
                        Utilities.CopyToClipboard(builder.ToString());
                    }
                }
            }
            catch
            {
            }
        }

        private void miSessionCopyEntire_Click(object sender, EventArgs e)
        {
            this.actSessionCopy();
        }

        private void miSessionCopyHeaders_Click(object sender, EventArgs e)
        {
            this.actSessionCopyHeaders();
        }

        private void miSessionCopyHeadlines_Click(object sender, EventArgs e)
        {
            this.actSessionCopyHeadlines();
        }

        private void miSessionCopyResponseAsDataURI_Click(object sender, EventArgs e)
        {
            try
            {
                Session[] selectedSessions = this.GetSelectedSessions();
                if (selectedSessions.Length >= 1)
                {
                    StringBuilder builder = new StringBuilder(0x200);
                    bool flag = true;
                    foreach (Session session in selectedSessions)
                    {
                        if (session.bHasResponse)
                        {
                            if (!flag)
                            {
                                builder.Append(Environment.NewLine);
                            }
                            builder.Append("data:");
                            builder.Append(string.IsNullOrEmpty(session.oResponse.MIMEType) ? "application/octet-stream" : session.oResponse.MIMEType);
                            builder.Append(";base64,");
                            builder.Append(Convert.ToBase64String(session.responseBodyBytes));
                            flag = false;
                        }
                    }
                    Utilities.CopyToClipboard(builder.ToString());
                }
            }
            catch (Exception exception)
            {
                FiddlerApplication.ReportException(exception);
            }
        }

        private void miSessionCopySummary_Click(object sender, EventArgs e)
        {
            this.actSessionCopySummary();
        }

        private void miSessionCopyURL_Click(object sender, EventArgs e)
        {
            this.actSessionCopyURL();
        }

        private void miSessionFilter_Popup(object sender, EventArgs e)
        {
            this.miSessionFilter.MenuItems.Clear();
            MenuItem item = new MenuItem("&Show");
            MenuItem item2 = new MenuItem("&Hide");
            item2.MenuItems.Add("Process=");
            item2.MenuItems.Add("Process=");
            item2.MenuItems.Add("Host=");
            item2.MenuItems.Add("");
            MenuItem item3 = new MenuItem("-");
            MenuItem item4 = new MenuItem("&List Filters");
            item4.Click += delegate(object s, EventArgs eA)
            {
                Splitter splitter = new Splitter
                {
                    Dock = DockStyle.Bottom
                };
                this.pnlSessions.Controls.Add(splitter);
                FlowLayoutPanel panel = new FlowLayoutPanel
                {
                    Dock = DockStyle.Bottom,
                    AutoScroll = true,
                    Height = 100
                };
                this.pnlSessions.Controls.Add(panel);
                Label label = new Label
                {
                    Font = new Font(this.Font, FontStyle.Bold),
                    Dock = DockStyle.Top,
                    Text = "Fi&lters"
                };
                panel.Controls.Add(label);
                for (int j = 0; j < 12; j++)
                {
                    LinkLabel label2 = new LinkLabel
                    {
                        Text = "W" + new string('x', j) + "g",
                        AutoSize = true
                    };
                    panel.Controls.Add(label2);
                    label2.Click += (ss, ee) => MessageBox.Show("ouch");
                }
            };
            this.miSessionFilter.MenuItems.AddRange(new MenuItem[] { item, item2, item3, item4 });
        }

        private void miSessionInspectNewWindow_Click(object sender, EventArgs e)
        {
            this.actInspectInNewWindow();
        }

        private void miSessionListScroll_Click(object sender, EventArgs e)
        {
            CONFIG.bAutoScroll = !this.miSessionListScroll.Checked;
            this.miViewAutoScroll.Checked = this.miSessionListScroll.Checked = CONFIG.bAutoScroll;
        }

        private void miSessionMarkColor_Click(object sender, EventArgs e)
        {
            if ((sender == this.miSessionMarkRed) || (sender == this.miEditMarkRed))
            {
                this.actSessionMark(System.Drawing.Color.Red);
            }
            else if ((sender == this.miSessionMarkBlue) || (sender == this.miEditMarkBlue))
            {
                this.actSessionMark(System.Drawing.Color.Blue);
            }
            else if ((sender == this.miSessionMarkGold) || (sender == this.miEditMarkGold))
            {
                this.actSessionMark(System.Drawing.Color.Gold);
            }
            else if ((sender == this.miSessionMarkGreen) || (sender == this.miEditMarkGreen))
            {
                this.actSessionMark(System.Drawing.Color.Green);
            }
            else if ((sender == this.miSessionMarkOrange) || (sender == this.miEditMarkOrange))
            {
                this.actSessionMark(System.Drawing.Color.Orange);
            }
            else if ((sender == this.miSessionMarkPurple) || (sender == this.miEditMarkPurple))
            {
                this.actSessionMark(System.Drawing.Color.Purple);
            }
            else if ((sender == this.miSessionMarkUnmark) || (sender == this.miEditMarkUnmark))
            {
                this.actSessionMark(System.Drawing.Color.Empty);
            }
        }

        private void miSessionProperties_Click(object sender, EventArgs e)
        {
            this.actViewSessionProperties();
        }

        private void miSessionReissueComposer_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = FiddlerApplication.UI.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                FiddlerApplication.DoComposeByCloning(firstSelectedSession);
            }
        }

        private void miSessionReissueEdited_Click(object sender, EventArgs e)
        {
            this.actReissueSelected(true);
        }

        private void miSessionReissueInIE_Click(object sender, EventArgs e)
        {
            Session[] selectedSessions = this.GetSelectedSessions();
            if (selectedSessions.Length < 1)
            {
                MessageBox.Show("Please select sessions to revisit.", "Nothing to Do");
            }
            else
            {
                for (int i = 0; i < selectedSessions.Length; i++)
                {
                    Utilities.RunExecutable("iexplore.exe", selectedSessions[i].fullUrl);
                }
            }
        }

        private void miSessionReissueRequests_Click(object sender, EventArgs e)
        {
            this.actReissueSelected(false);
        }

        private void miSessionReissueUnconditionally_Click(object sender, EventArgs e)
        {
            this.actUnconditionallyReissueSelected();
        }

        private void miSessionRemoveAll_Click(object sender, EventArgs e)
        {
            int num = FiddlerApplication.Prefs.GetInt32Pref("fiddler.ui.CtrlX.PromptIfMoreThan", 0);
            if (((num <= 0) || (this.lvSessions.Items.Count < num)) || (DialogResult.No != MessageBox.Show("Remove all " + this.lvSessions.Items.Count.ToString() + " sessions?", "Confirm Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)))
            {
                if (FiddlerApplication.Prefs.GetBoolPref("fiddler.ui.CtrlX.KeepMarked", false))
                {
                    FiddlerApplication.UI.sbpInfo.Text = "Clearing all unmarked sessions";
                    this.TrimSessionList(0);
                    FiddlerApplication.oProxy.PurgeServerPipePool();
                    FiddlerApplication.UI.sbpInfo.Text = "Cleared all unmarked sessions";
                }
                else
                {
                    this.actRemoveAllSessions();
                }
            }
        }

        private void miSessionRemoveSelected_Click(object sender, EventArgs e)
        {
            this.actRemoveSelectedSessions();
        }

        private void miSessionRemoveUnselected_Click(object sender, EventArgs e)
        {
            this.actRemoveUnselectedSessions();
        }

        private void miSessionReplayResponse_Click(object sender, EventArgs e)
        {
            if (this.lvSessions.SelectedCount == 2)
            {
                Session session3;
                Session session4;
                Session tag = this.lvSessions.SelectedItems[0].Tag as Session;
                Session session2 = this.lvSessions.SelectedItems[1].Tag as Session;
                if (tag.state >= session2.state)
                {
                    session3 = session2;
                    session4 = tag;
                }
                else
                {
                    session3 = tag;
                    session4 = session2;
                }
                if (session4.bHasResponse && ((session3.state == SessionStates.HandTamperRequest) || (session3.state == SessionStates.HandTamperResponse)))
                {
                    session3.responseBodyBytes = Utilities.Dupe(session4.responseBodyBytes);
                    session3.oResponse.headers = (HTTPResponseHeaders)session4.oResponse.headers.Clone();
                    session3.state = SessionStates.HandTamperResponse;
                    this.lvSessions.SelectedItems.Clear();
                    session3.ViewItem.Selected = session3.ViewItem.Focused = true;
                    this.actRefreshInspectorsIfNeeded(session3);
                    this.actUpdateInspector(false, true);
                    return;
                }
            }
            MessageBox.Show("You must select two sessions, one of which has a response,\nand one of which is breakpointed awaiting a response.", "Invalid operation");
        }

        private void miSessionSaveEntire_Click(object sender, EventArgs e)
        {
            this.actSaveSessions();
        }

        private void miSessionSaveFullRequest_Click(object sender, EventArgs e)
        {
            this.actSaveRequests();
        }

        private void miSessionSaveFullResponse_Click(object sender, EventArgs e)
        {
            this.actSaveResponses();
        }

        private void miSessionSaveHeaders_Click(object sender, EventArgs e)
        {
            this.actSaveHeaders();
        }

        private void miSessionSaveRequestBody_Click(object sender, EventArgs e)
        {
            this.actSaveSessionRequestBody();
        }

        private void miSessionSaveResponseBody_Click(object sender, EventArgs e)
        {
            this.actSaveSessionResponseBody();
        }

        private void miSessionSaveToZip_Click(object sender, EventArgs e)
        {
            this.actSaveSessionsToZip();
        }

        private void miSessionSelectChildren_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                string fullUrl = firstSelectedSession.fullUrl;
                bool flag = false;
                if (Utilities.IsRedirectStatus(firstSelectedSession.responseCode) && (firstSelectedSession.oResponse != null))
                {
                    string str2 = firstSelectedSession.oResponse["Location"];
                    if (!string.IsNullOrEmpty(str2))
                    {
                        flag = true;
                        if ((!str2.StartsWith("/") && str2.Contains("://")) && (str2.IndexOf("://") < str2.IndexOf("/")))
                        {
                            fullUrl = str2;
                        }
                        else
                        {
                            Uri baseUri = new Uri(firstSelectedSession.fullUrl);
                            Uri uri2 = new Uri(baseUri, str2);
                            fullUrl = uri2.AbsoluteUri;
                        }
                    }
                }
                string str3 = firstSelectedSession.oRequest.headers.HTTPMethod + firstSelectedSession.fullUrl;
                int id = firstSelectedSession.id;
                FiddlerApplication.SuppressReportUpdates = true;
                this.lvSessions.BeginUpdate();
                this.lvSessions.SelectedItems.Clear();
                foreach (ListViewItem item in this.lvSessions.Items)
                {
                    Session tag = (Session)item.Tag;
                    if (tag.id <= id)
                    {
                        continue;
                    }
                    if (((tag != null) && (tag.oRequest != null)) && (tag.oRequest.headers != null))
                    {
                        if (flag)
                        {
                            if (!(tag.fullUrl == fullUrl))
                            {
                                goto Label_0188;
                            }
                            item.Selected = true;
                            item.Focused = true;
                            break;
                        }
                        if (tag.oRequest.headers.ExistsAndEquals("Referer", fullUrl))
                        {
                            item.Selected = true;
                            item.Focused = true;
                        }
                    }
                Label_0188:
                    if (str3.Equals(tag.oRequest.headers.HTTPMethod + tag.fullUrl))
                    {
                        break;
                    }
                }
                this.sbpInfo.Text = "Found " + this.lvSessions.SelectedCount.ToString() + " children.";
                firstSelectedSession.ViewItem.Selected = true;
                if (this.lvSessions.SelectedCount > 0)
                {
                    this.lvSessions.SelectedItems[0].EnsureVisible();
                }
                this.lvSessions.EndUpdate();
                FiddlerApplication.SuppressReportUpdates = false;
                this.actUpdateInspector(true, true);
            }
        }

        private void miSessionSelectDuplicates_Click(object sender, EventArgs e)
        {
            string sMatch;
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                firstSelectedSession.ViewItem.Focused = true;
                sMatch = firstSelectedSession.oRequest.headers.HTTPMethod + firstSelectedSession.fullUrl;
                this.actSelectSessionsMatchingCriteria(delegate(Session oS)
                {
                    return ((oS.oRequest != null) && (oS.oRequest.headers != null)) && sMatch.Equals(oS.oRequest.headers.HTTPMethod + oS.fullUrl, StringComparison.OrdinalIgnoreCase);
                });
                this.sbpInfo.Text = "Found " + ((this.lvSessions.SelectedCount - 1)).ToString() + " duplicates.";
            }
        }

        private void miSessionSelectParent_Click(object sender, EventArgs e)
        {
            Session firstSelectedSession = this.GetFirstSelectedSession();
            if (firstSelectedSession != null)
            {
                string str = firstSelectedSession.oRequest["Referer"];
                if ((str == null) || (str.Length < 1))
                {
                    this.sbpInfo.Text = "No Referer header was present; cannot find parent.";
                }
                else
                {
                    int id = firstSelectedSession.id;
                    Session session2 = null;
                    FiddlerApplication.SuppressReportUpdates = true;
                    this.lvSessions.BeginUpdate();
                    this.lvSessions.SelectedItems.Clear();
                    foreach (ListViewItem item in this.lvSessions.Items)
                    {
                        Session tag = (Session)item.Tag;
                        if ((((tag.id < id) && (tag != null)) && ((tag.oRequest != null) && (tag.oRequest.headers != null))) && (tag.fullUrl.Equals(str) && ((session2 == null) || (session2.id < tag.id))))
                        {
                            session2 = tag;
                        }
                    }
                    this.sbpInfo.Text = string.Empty;
                    if (session2 != null)
                    {
                        session2.ViewItem.Selected = true;
                        session2.ViewItem.Focused = true;
                        session2.ViewItem.EnsureVisible();
                    }
                    else
                    {
                        this.sbpInfo.Text = "Parent session was not found.";
                    }
                    this.lvSessions.EndUpdate();
                    FiddlerApplication.SuppressReportUpdates = false;
                    this.actUpdateInspector(true, true);
                }
            }
        }

        private void miSessionUnlock_Click(object sender, EventArgs e)
        {
            this.actToggleSessionUnlock();
        }

        private void miSessionWinDiff_Click(object sender, EventArgs e)
        {
            if (this.lvSessions.SelectedCount == 2)
            {
                this.actDoCompareSessions((Session)this.lvSessions.SelectedItems[0].Tag, (Session)this.lvSessions.SelectedItems[1].Tag);
            }
        }

        private void miSquish_Click(object sender, EventArgs e)
        {
            this.actToggleSquish();
        }

        private void miToolsBase64_Click(object sender, EventArgs e)
        {
            this.actShowTextWizard(null);
        }

        private void miToolsClearCache_Click(object sender, EventArgs e)
        {
            this.actClearWinINETCache();
        }

        private void miToolsClearCookies_Click(object sender, EventArgs e)
        {
            this.actClearWinINETCookies();
        }

        private void miToolsFind_Click(object sender, EventArgs e)
        {
            this.actDoFind();
        }

        private void miToolsInternetOptions_Click(object sender, EventArgs e)
        {
            this.actLaunchIEProxy();
        }

        private void miToolsOptions_Click(object sender, EventArgs e)
        {
            this.actShowOptions();
        }

        private void miViewAutoScroll_Click(object sender, EventArgs e)
        {
            CONFIG.bAutoScroll = !this.miViewAutoScroll.Checked;
            this.miViewAutoScroll.Checked = this.miSessionListScroll.Checked = CONFIG.bAutoScroll;
        }

        private void miViewBuilder_Click(object sender, EventArgs e)
        {
            UIComposer.EnsureShowing();
        }

        private void miViewInspector_Click(object sender, EventArgs e)
        {
            this.tabsViews.SelectedTab = this.pageInspector;
        }

        private void miViewLayout_Click(object sender, EventArgs e)
        {
            MenuItem item = sender as MenuItem;
            if ((item != null) && !item.Checked)
            {
                int iLayoutMode = 0;
                if (sender == this.miViewStacked)
                {
                    iLayoutMode = 1;
                }
                else if (sender == this.miViewWide)
                {
                    iLayoutMode = 2;
                }
                this.actChangeToLayout(iLayoutMode);
            }
        }

        private void miViewRefresh_Click(object sender, EventArgs e)
        {
            this.actRefreshUI();
            foreach (Session session in FiddlerApplication.UI.GetSelectedSessions())
            {
                this._RefreshSessionListViewItem(session, session.ViewItem);
            }
        }

        private void miViewStatistics_Click(object sender, EventArgs e)
        {
            this.tabsViews.SelectedTab = this.pageStatistics;
        }

        private void miViewStayOnTop_Click(object sender, EventArgs e)
        {
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.stayontop", !this.miViewStayOnTop.Checked);
        }

        private void miViewToolbar_Click(object sender, EventArgs e)
        {
            this.miViewToolbar.Checked = !this.miViewToolbar.Checked;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.toolbar.visible", this.miViewToolbar.Checked);
        }

        private void mnuEdit_Popup(object sender, EventArgs e)
        {
            this.mnuEditMark.Enabled = 0 < this.lvSessions.SelectedCount;
            this.miEditUnlock.Enabled = this.lvSessions.SelectedCount == 1;
            if (this.miEditUnlock.Enabled)
            {
                Session firstSelectedSession = this.GetFirstSelectedSession();
                this.miEditUnlock.Checked = firstSelectedSession.oFlags.ContainsKey("x-Unlocked");
            }
            this.miEditPaste.Enabled = Clipboard.ContainsFileDropList() || Clipboard.ContainsImage();
            if (!this.miEditPaste.Enabled && Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();
                if (text.IndexOf("data:", 0, Math.Min(text.Length, 0x40)) > -1)
                {
                    this.miEditPaste.Enabled = true;
                }
            }
        }

        private void mnuEditRemove_Popup(object sender, EventArgs e)
        {
            this.miEditRemoveSelected.Enabled = 0 < this.lvSessions.SelectedCount;
            this.miEditRemoveUnselected.Enabled = 0 < this.lvSessions.SelectedCount;
        }

        private void mnuFile_Popup(object sender, EventArgs e)
        {
            this.mnuFileSave.Enabled = 0 < this.lvSessions.Items.Count;
            if (this.mnuFileExport != null)
            {
                this.mnuFileExport.Enabled = this.mnuFileSave.Enabled;
            }
        }

        private void mnuFileMRU_Popup(object sender, EventArgs e)
        {
            EventHandler handler = null;
            try
            {
                MenuItem[] itemArray;
                this.mnuFileMRU.MenuItems.Clear();
                this.oSAZMRU.RefreshList();
                string[] list = this.oSAZMRU.GetList();
                if (list.Length == 0)
                {
                    itemArray = new MenuItem[] { new MenuItem("<None>") };
                    itemArray[0].Enabled = false;
                }
                else
                {
                    itemArray = new MenuItem[3 + list.Length];
                    for (int i = 0; i < list.Length; i++)
                    {
                        if (list[i] != null)
                        {
                            itemArray[i] = new MenuItem(string.Format("&{0:x}. {1}", i, Utilities.CompactPath(list[i], 0x30)));
                            itemArray[i].Tag = list[i];
                            if (handler == null)
                            {
                                handler = delegate(object o, EventArgs s)
                                {
                                    this.actLoadSessionArchive((o as MenuItem).Tag as string);
                                };
                            }
                            itemArray[i].Click += handler;
                        }
                    }
                    itemArray[itemArray.Length - 3] = this.miFileMRUSplit;
                    itemArray[itemArray.Length - 2] = this.miFileMRUPrune;
                    itemArray[itemArray.Length - 1] = this.miFileMRUClear;
                }
                this.mnuFileMRU.MenuItems.AddRange(itemArray);
            }
            catch (Exception)
            {
            }
        }

        private void mnuFileSave_Popup(object sender, EventArgs e)
        {
            this.mnuFileSaveRequest.Enabled = this.mnuFileSaveResponse.Enabled = this.mnuFileSaveSessions.Enabled = 0 < this.lvSessions.SelectedItems.Count;
        }

        private void mnuSessionContext_Popup(object sender, EventArgs e)
        {
            this._ptContextPopup = Cursor.Position;
            this.miSessionRemoveAll.Enabled = this.lvSessions.Items.Count > 0;
            int selectedCount = this.lvSessions.SelectedCount;
            this.miSessionReplay.Enabled = this.miSessionFilter.Enabled = this.miSessionMark.Enabled = this.miSessionCopy.Enabled = this.miSessionRemoveSelected.Enabled = this.miSessionRemoveUnselected.Enabled = this.miSessionSave.Enabled = this.miSessionSaveEntire.Enabled = this.miSessionSaveHeaders.Enabled = this.miSessionSaveRequestBody.Enabled = this.miSessionAddComment.Enabled = this.miSessionSaveResponseBody.Enabled = this.miSessionAbort.Enabled = selectedCount > 0;
            this.miSessionInspectNewWindow.Enabled = this.miSessionProperties.Enabled = this.miSessionSelect.Enabled = selectedCount == 1;
            this.miSessionWinDiff.Enabled = selectedCount == 2;
            this.miSessionFilter.Visible = false;
            bool flag = selectedCount == 2;
            if (flag)
            {
                flag = ((this.lvSessions.SelectedItems[0].Tag as Session).state > SessionStates.HandTamperResponse) ^ ((this.lvSessions.SelectedItems[1].Tag as Session).state > SessionStates.HandTamperResponse);
            }
            this.miSessionReplayResponse.Enabled = flag;
            if (selectedCount == 1)
            {
                Session tag = this.lvSessions.SelectedItems[0].Tag as Session;
                this.miSessionAbort.Enabled = (tag.state < SessionStates.Done) || tag.isAnyFlagSet(SessionFlags.IsWebSocketTunnel | SessionFlags.IsDecryptingTunnel | SessionFlags.IsBlindTunnel);
                this.miSessionUnlock.Enabled = tag.state >= SessionStates.Done;
                this.miSessionUnlock.Checked = tag.oFlags.ContainsKey("X-Unlocked");
                this.miSessionCOMETPeek.Enabled = tag.state == SessionStates.ReadingResponse;
            }
            else
            {
                this.miSessionCOMETPeek.Enabled = this.miSessionUnlock.Enabled = this.miSessionUnlock.Checked = false;
            }
        }

        private void mnuTools_Popup(object sender, EventArgs e)
        {
            this.miToolsCompare.Enabled = 2 == this.lvSessions.SelectedCount;
        }

        private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.actRestoreWindow();
            }
        }

        private void OnPrefChange(object sender, PrefChangeEventArgs oPref)
        {
            string str;
            if (!FiddlerApplication.isClosing && ((str = oPref.PrefName) != null))
            {
                if (!(str == "fiddler.ui.rules.removeencoding"))
                {
                    if (!(str == "fiddler.ui.toolbar.visible"))
                    {
                        if (!(str == "fiddler.ui.stayontop"))
                        {
                            if (str == "fiddler.ui.sessionlist.updateinterval")
                            {
                                this.lvSessions.uiAsyncUpdateInterval = FiddlerApplication.Prefs.GetInt32Pref("fiddler.ui.sessionlist.updateinterval", 80);
                            }
                        }
                        else
                        {
                            this.miViewStayOnTop.Checked = oPref.ValueBool;
                            base.TopMost = this.miViewStayOnTop.Checked;
                        }
                    }
                    else
                    {
                        this.miViewToolbar.Checked = oPref.ValueBool;
                    }
                }
                else
                {
                    this.miRulesRemoveEncoding.Checked = oPref.ValueBool;
                }
            }
        }

        private void oReportingQueueTimer_Tick(object sender, EventArgs e)
        {
            oReportingQueueTimer.Stop();
            this.actUpdateReport();
        }

        private static bool PerformUpgradeIfPending()
        {
            try
            {
                RegistryKey oReg = Registry.CurrentUser.OpenSubKey(CONFIG.GetRegPath("Root"), true);
                if (oReg == null)
                {
                    return false;
                }
                bool flag = Utilities.GetRegistryBool(oReg, "UpdatePending", false);
                oReg.DeleteValue("UpdatePending", false);
                oReg.Close();
                if (!flag)
                {
                    return false;
                }
                Process.Start(Path.GetDirectoryName(Application.ExecutablePath) + @"\UpdateFiddler.exe");
                return true;
            }
            catch
            {
                return false;
            }
        }

        [CodeDescription("Remove the named tab in the top-level View")]
        public void RemoveView(string sViewTabName)
        {
            foreach (TabPage page in this.tabsViews.TabPages)
            {
                if (string.Equals(page.Text, sViewTabName, StringComparison.OrdinalIgnoreCase))
                {
                    this.tabsViews.TabPages.Remove(page);
                    break;
                }
            }
        }

        [CodeDescription("Resume a session currently paused at a breakpoint.")]
        public void ResumeBreakpointedSession(Session oSession)
        {
            if (oSession != null)
            {
                switch (oSession.state)
                {
                    case SessionStates.HandTamperRequest:
                        this.actUpdateRequest(oSession);
                        if (oSession.ViewItem != null)
                        {
                            oSession.ViewItem.ImageIndex = 0;
                        }
                        break;

                    case SessionStates.HandTamperResponse:
                        this.actUpdateResponse(oSession);
                        if (oSession.ViewItem != null)
                        {
                            oSession.ViewItem.ImageIndex = 2;
                        }
                        break;
                }
                this.btnTamperSendServer.Enabled = this.btnTamperSendClient.Enabled = false;
                oSession.ThreadResume();
            }
        }

        private static void RunMain(string[] arrArgs)
        {
            if ((arrArgs.Length != 0) || !PerformUpgradeIfPending())
            {
                Mutex mutex;
                FiddlerApplication._frmSplash = new SplashScreen();
                if (!CONFIG.QuietMode)
                {
                    if ((Keys.Shift == Control.ModifierKeys) && (DialogResult.Yes == MessageBox.Show("The SHIFT Key is down. Would you like to start Fiddler with default appearance settings?", "Fiddler Safe Mode", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)))
                    {
                        CONFIG.bRevertToDefaultLayout = true;
                        FiddlerApplication.Prefs.RemovePref("fiddler.inspectors.hidelist");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.font.size");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.lastview");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.stayontop");
                        FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.toolbar.visible", true);
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.rules.hideimages");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.layout.mode");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.rules.hideconnects");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.rules.removeencoding");
                        FiddlerApplication.Prefs.RemovePref("fiddler.ui.sessionlist.updateinterval");
                    }
                    FiddlerApplication._frmSplash.Show();
                }
                FiddlerApplication._frmSplash.IndicateProgress("Searching for running instance...");
                try
                {
                    string name = !CONFIG.bIsViewOnly ? (@"Global\FiddlerUser_" + Environment.UserName) : ("FiddlerViewer" + Environment.TickCount.ToString());
                    mutex = new Mutex(false, name);
                }
                catch (Exception exception)
                {
                    FiddlerApplication._frmSplash.Close();
                    FiddlerApplication.DoNotifyUser("Fiddler appears to be running in this user account (mutex fail).\n\n" + Utilities.DescribeException(exception), "Fiddler Startup Aborted", MessageBoxIcon.Hand);
                    return;
                }
                using (mutex)
                {
                    bool flag = true;
                    if (!mutex.WaitOne(40, false))
                    {
                        FiddlerApplication._frmSplash.Close();
                        IntPtr hWnd = Utilities.FindWindow(null, "Fiddler - HTTP Debugging Proxy");
                        if (0L != hWnd.ToInt64())
                        {
                            Utilities.SendMessage(hWnd, 0x312, IntPtr.Zero, (IntPtr)((CONFIG.iHotkey << 0x10) + CONFIG.iHotkeyMod));
                            for (int i = 0; i < arrArgs.Length; i++)
                            {
                                if (arrArgs[i].EndsWith(".saz", StringComparison.OrdinalIgnoreCase))
                                {
                                    Utilities.SendDataStruct lParam = new Utilities.SendDataStruct();
                                    lParam.dwData = (IntPtr)0xeefa;
                                    lParam.strData = arrArgs[i];
                                    lParam.cbData = Encoding.Unicode.GetByteCount(lParam.strData);
                                    Utilities.SendWMCopyMessage(hWnd, 0x4a, IntPtr.Zero, ref lParam);
                                }
                            }
                        }
                        else if (DialogResult.Yes == MessageBox.Show("Fiddler appears to be running in this user account. Maybe in a terminal services session?\n\nIf you run two copies of Fiddler at the same time, your settings may be corrupted.\n\nStart Fiddler anyway?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2))
                        {
                            flag = false;
                        }
                        if (flag)
                        {
                            return;
                        }
                    }
                    FiddlerApplication._SetXceedLicenseKeys();
                    FiddlerApplication._frmMain = new frmViewer();
                    FiddlerApplication._frmSplash.IndicateProgress("Loading AutoResponder...");
                    FiddlerApplication._AutoResponder = new AutoResponder();
                    FiddlerApplication._AutoResponder.LoadRules();
                    FiddlerApplication._frmSplash.IndicateProgress("Creating Proxy...");
                    FiddlerApplication.oProxy = new Proxy(true);
                    FiddlerApplication.Log.LogString("Fiddler Running...");
                    Application.Run(FiddlerApplication._frmMain);
                }
            }
        }

        private void SaveFilesForDiffer(string sFile1, string sFile2, Session oSess1, Session oSess2)
        {
            Utilities.EnsureOverwritable(sFile1);
            Utilities.EnsureOverwritable(sFile2);
            if (FiddlerApplication.Prefs.GetBoolPref("fiddler.differ.DecodeFirst", true))
            {
                try
                {
                    oSess1.utilDecodeRequest();
                    oSess1.utilDecodeResponse();
                    oSess2.utilDecodeRequest();
                    oSess2.utilDecodeResponse();
                }
                catch (Exception)
                {
                }
            }
            if (!FiddlerApplication.Prefs.GetBoolPref("fiddler.differ.ultradiff", true))
            {
                oSess1.SaveSession(sFile1, false);
                oSess2.SaveSession(sFile2, false);
            }
            else
            {
                string str7;
                string str8;
                FileStream stream = new FileStream(sFile1, FileMode.Create, FileAccess.Write);
                FileStream stream2 = new FileStream(sFile2, FileMode.Create, FileAccess.Write);
                StreamWriter writer = new StreamWriter(stream);
                StreamWriter writer2 = new StreamWriter(stream2);
                string hTTPMethod = oSess1.oRequest.headers.HTTPMethod;
                string str2 = oSess2.oRequest.headers.HTTPMethod;
                string fullUrl = oSess1.fullUrl;
                string str4 = oSess2.fullUrl;
                string hTTPVersion = oSess1.oRequest.headers.HTTPVersion;
                string str6 = oSess2.oRequest.headers.HTTPVersion;
                if (((hTTPMethod == str2) && (fullUrl == str4)) && (hTTPVersion == str6))
                {
                    writer.Write("{0} {1} {2}\r\n", hTTPMethod, fullUrl, hTTPVersion);
                    writer2.Write("{0} {1} {2}\r\n", str2, str4, str6);
                }
                else
                {
                    int length = getFirstMismatchedCharacter(fullUrl, str4);
                    if (length > -1)
                    {
                        fullUrl = fullUrl.Substring(0, length) + "\r\n>>\t" + fullUrl.Substring(length, fullUrl.Length - length);
                        str4 = str4.Substring(0, length) + "\r\n>>\t" + str4.Substring(length, str4.Length - length);
                    }
                    writer.Write("{0}\r\n{1}\r\n{2}\r\n\r\n", hTTPMethod, fullUrl, hTTPVersion);
                    writer2.Write("{0}\r\n{1}\r\n{2}\r\n\r\n", str2, str4, str6);
                }
                this.GetDiffFormattedHeaders(oSess1.oRequest.headers, oSess2.oRequest.headers, out str7, out str8);
                writer.WriteLine(str7);
                writer2.WriteLine(str8);
                writer.Flush();
                writer2.Flush();
                if (oSess1.requestBodyBytes != null)
                {
                    stream.Write(oSess1.requestBodyBytes, 0, oSess1.requestBodyBytes.Length);
                }
                if (oSess2.requestBodyBytes != null)
                {
                    stream2.Write(oSess2.requestBodyBytes, 0, oSess2.requestBodyBytes.Length);
                }
                writer.WriteLine("\r\n------------------------------------------------------------\r\n");
                writer2.WriteLine("\r\n------------------------------------------------------------\r\n");
                writer.Flush();
                writer2.Flush();
                if (((oSess1.oResponse != null) && (oSess1.oResponse.headers != null)) && ((oSess2.oResponse != null) && (oSess2.oResponse.headers != null)))
                {
                    hTTPVersion = oSess1.oResponse.headers.HTTPVersion;
                    str6 = oSess2.oResponse.headers.HTTPVersion;
                    string hTTPResponseStatus = oSess1.oResponse.headers.HTTPResponseStatus;
                    string str10 = oSess2.oResponse.headers.HTTPResponseStatus;
                    writer.Write("{0} {1}\r\n", hTTPVersion, hTTPResponseStatus);
                    writer2.Write("{0} {1}\r\n", str6, str10);
                    this.GetDiffFormattedHeaders(oSess1.oResponse.headers, oSess2.oResponse.headers, out str7, out str8);
                    writer.WriteLine(str7);
                    writer2.WriteLine(str8);
                    writer.Flush();
                    writer2.Flush();
                }
                else
                {
                    if ((oSess1.oResponse != null) && (oSess1.oResponse.headers != null))
                    {
                        byte[] buffer = oSess1.oResponse.headers.ToByteArray(true, true);
                        stream.Write(buffer, 0, buffer.Length);
                    }
                    else
                    {
                        stream.WriteByte(13);
                        stream.WriteByte(10);
                    }
                    if ((oSess2.oResponse != null) && (oSess2.oResponse.headers != null))
                    {
                        byte[] buffer2 = oSess2.oResponse.headers.ToByteArray(true, true);
                        stream2.Write(buffer2, 0, buffer2.Length);
                    }
                    else
                    {
                        stream2.WriteByte(13);
                        stream2.WriteByte(10);
                    }
                }
                if (oSess1.responseBodyBytes != null)
                {
                    stream.Write(oSess1.responseBodyBytes, 0, oSess1.responseBodyBytes.Length);
                }
                if (oSess2.responseBodyBytes != null)
                {
                    stream2.Write(oSess2.responseBodyBytes, 0, oSess2.responseBodyBytes.Length);
                }
                stream.Close();
                stream2.Close();
            }
        }

        private void sbStatus_MouseMove(object sender, MouseEventArgs e)
        {
            if (!CONFIG.bIsViewOnly)
            {
                if (e.Location.X < ((this.sbpCapture.Width + this.sbpProcessFilter.Width) + this.sbpBreakpoints.Width))
                {
                    this.sbStatus.Cursor = Cursors.Hand;
                }
                else
                {
                    this.sbStatus.Cursor = Cursors.Default;
                }
            }
        }

        private void sbStatus_PanelClick(object sender, StatusBarPanelClickEventArgs e)
        {
            EventHandler handler = null;
            EventHandler handler2 = null;
            EventHandler handler3 = null;
            EventHandler handler4 = null;
            if (e.Clicks == 1)
            {
                if (((e.StatusBarPanel == this.sbpCapture) && ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right))) && !CONFIG.bIsViewOnly)
                {
                    lock (this)
                    {
                        this.actToggleCapture();
                    }
                }
                else if ((e.StatusBarPanel == this.sbpProcessFilter) && !CONFIG.bIsViewOnly)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        CONFIG.iShowProcessFilter = ProcessFilterCategories.All;
                        this.uihlpUpdateProcessFilterStatus();
                        FiddlerToolbar.ClearProcessFilter();
                    }
                    else
                    {
                        ContextMenuStrip strip = new ContextMenuStrip();
                        if (handler == null)
                        {
                            handler = delegate(object s, EventArgs ea)
                            {
                                CONFIG.iShowProcessFilter = ProcessFilterCategories.All;
                                this.uihlpUpdateProcessFilterStatus();
                                FiddlerToolbar.ClearProcessFilter();
                            };
                        }
                        strip.Items.Add("All Processes", (Bitmap)this.imglSessionIcons.Images[0x19]).Click += handler;
                        if (handler2 == null)
                        {
                            handler2 = delegate(object s, EventArgs ea)
                            {
                                CONFIG.iShowProcessFilter = ProcessFilterCategories.Browsers;
                                this.uihlpUpdateProcessFilterStatus();
                                FiddlerToolbar.ClearProcessFilter();
                            };
                        }
                        strip.Items.Add("Web Browsers", (Bitmap)this.imglSessionIcons.Images[0x1a]).Click += handler2;
                        if (handler3 == null)
                        {
                            handler3 = delegate(object s, EventArgs ea)
                            {
                                CONFIG.iShowProcessFilter = ProcessFilterCategories.NonBrowsers;
                                this.uihlpUpdateProcessFilterStatus();
                                FiddlerToolbar.ClearProcessFilter();
                            };
                        }
                        strip.Items.Add("Non-Browser", (Bitmap)this.imglSessionIcons.Images[20]).Click += handler3;
                        if (handler4 == null)
                        {
                            handler4 = delegate(object s, EventArgs ea)
                            {
                                CONFIG.iShowProcessFilter = ProcessFilterCategories.HideAll;
                                this.uihlpUpdateProcessFilterStatus();
                                FiddlerToolbar.ClearProcessFilter();
                            };
                        }
                        strip.Items.Add("Hide All", (Bitmap)this.imglSessionIcons.Images[14]).Click += handler4;
                        strip.Show(this.sbStatus, new Point(this.sbpCapture.Width, 0), ToolStripDropDownDirection.AboveRight);
                    }
                }
                else if (e.StatusBarPanel == this.sbpBreakpoints)
                {
                    lock (this)
                    {
                        MenuItem item2 = null;
                        if (this.miRulesBreakAtNothing.Checked)
                        {
                            item2 = (e.Button == MouseButtons.Left) ? this.miRulesBreakAtRequest : this.miRulesBreakAtResponse;
                        }
                        if (this.miRulesBreakAtRequest.Checked)
                        {
                            item2 = (e.Button == MouseButtons.Left) ? this.miRulesBreakAtResponse : this.miRulesBreakAtNothing;
                        }
                        if (this.miRulesBreakAtResponse.Checked)
                        {
                            item2 = (e.Button == MouseButtons.Left) ? this.miRulesBreakAtNothing : this.miRulesBreakAtNothing;
                        }
                        if (item2 != null)
                        {
                            this.miRulesBreakAtNothing.Checked = false;
                            this.miRulesBreakAtRequest.Checked = false;
                            this.miRulesBreakAtResponse.Checked = false;
                            item2.Checked = true;
                            this._UpdateBreakpointMenu();
                        }
                    }
                }
            }
        }

        private static void SetMenuItemCheckedFromPref(MenuItem oMI, string sPref)
        {
            oMI.Checked = FiddlerApplication.Prefs.GetBoolPref(sPref, false);
        }

        public void SetStatusText(string sMessage)
        {
            if (!FiddlerApplication.isClosing)
            {
                if (base.InvokeRequired)
                {
                    base.BeginInvoke(new setStringDelegate(this.SetStatusText), new object[] { sMessage });
                }
                else
                {
                    this.sbpInfo.Text = sMessage;
                }
            }
        }

        public void ShowAlert(frmAlert oAlert)
        {
            oAlert.StartPosition = FormStartPosition.CenterScreen;
            oAlert.Show(this);
        }

        private void splitterInspector_DoubleClick(object sender, EventArgs e)
        {
            if (DockStyle.Left == this.splitterInspector.Dock)
            {
                if (this.tabsRequest.Width > 0x4b)
                {
                    this.tabsRequest.Width = 0x4b;
                }
                else
                {
                    this.tabsRequest.Width = Math.Max(100, (base.Width - 100) / 2);
                }
            }
            else if (this.tabsRequest.Height > 30)
            {
                this.tabsRequest.Height = 30;
            }
            else
            {
                this.tabsRequest.Height = Math.Max(100, (base.Height - 100) / 2);
            }
        }

        private void splitterMain_DoubleClick(object sender, EventArgs e)
        {
            int num = 0;
            foreach (ColumnHeader header in this.lvSessions.Columns)
            {
                num += header.Width;
            }
            this.pnlSessions.Width = Math.Min((int)(Screen.FromControl(this.btnSquish).WorkingArea.Width - 40), (int)(num + 20));
        }

        private void tabsRequest_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!FiddlerApplication.isClosing && (this.tabsRequest.SelectedIndex >= 0))
            {
                this.actUpdateInspector(true, false);
            }
        }

        private void tabsResponse_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!FiddlerApplication.isClosing && (this.tabsResponse.SelectedIndex >= 0))
            {
                this.tabsResponse.TabPages[this.tabsResponse.SelectedIndex].Focus();
                this.actUpdateInspector(false, true);
            }
        }

        private void tabsViews_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                Point pt = this.tabsViews.PointToClient(new Point(e.X, e.Y));
                if (pt.Y < this.tabsViews.DisplayRectangle.Top)
                {
                    TabPage page = this._GetTabPageFromPoint(pt);
                    if ((page != null) && (this.tabsViews.SelectedTab != page))
                    {
                        this.tabsViews.SelectedTab = page;
                        if (this.tabsViews.RowCount > 1)
                        {
                            Rectangle tabRect = this.tabsViews.GetTabRect(this.tabsViews.TabPages.IndexOf(page));
                            Point p = new Point(tabRect.Left + (tabRect.Width / 2), tabRect.Top + (tabRect.Height / 2));
                            Cursor.Position = this.tabsViews.PointToScreen(p);
                        }
                    }
                }
            }
            catch
            {
            }
        }

        private void tabsViews_MouseClick(object sender, MouseEventArgs e)
        {
            if ((e.Button == MouseButtons.Middle) || ((e.Button == MouseButtons.Right) && (Control.ModifierKeys == Keys.Control)))
            {
                try
                {
                    Point pt = new Point(e.X, e.Y);
                    if (pt.Y < this.tabsViews.DisplayRectangle.Top)
                    {
                        TabPage page = this._GetTabPageFromPoint(pt);
                        if (page != null)
                        {
                            this.tabsViews.TabPages.Remove(page);
                        }
                    }
                }
                catch
                {
                }
            }
        }

        private void tabsViews_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!FiddlerApplication.isClosing)
            {
                if (this.pageBuilder == this.tabsViews.SelectedTab)
                {
                    UIComposer.EnsureReady();
                }
                this.actUpdateInspector(true, true);
                this.actReportStatistics(true);
            }
        }

        public void TrimSessionList(int iTrimTo)
        {
            if (this.lvSessions.TotalItemCount() > iTrimTo)
            {
                if (base.InvokeRequired)
                {
                    base.Invoke(new trimSessionListDelegate(this.TrimSessionList), new object[] { iTrimTo });
                }
                else
                {
                    this._internalTrimSessionList(iTrimTo, true);
                }
            }
        }

        private void txtExec_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("Fiddler.Session[]"))
            {
                Session[] data = (Session[])e.Data.GetData("Fiddler.Session[]");
                StringBuilder builder = new StringBuilder();
                foreach (Session session in data)
                {
                    builder.Append(session.fullUrl);
                    builder.Append(" ");
                }
                this.txtExec.SelectedText = builder.ToString();
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] strArray = (string[])e.Data.GetData("FileDrop", false);
                StringBuilder builder2 = new StringBuilder();
                foreach (string str in strArray)
                {
                    builder2.AppendFormat("\"{0}\" ", str);
                }
                this.txtExec.SelectedText = builder2.ToString();
            }
            else if (e.Data.GetDataPresent(DataFormats.Text))
            {
                this.txtExec.SelectedText = (string)e.Data.GetData(DataFormats.Text);
            }
            Utilities.SetForegroundWindow(base.Handle);
            this.txtExec.Focus();
            this.txtExec.SelectionLength = 0;
        }

        private void txtExec_DragOver(object sender, DragEventArgs e)
        {
            if ((e.Data.GetDataPresent("Fiddler.Session[]") || e.Data.GetDataPresent(DataFormats.FileDrop)) || e.Data.GetDataPresent(DataFormats.Text))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void txtExec_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData == (Keys.Control | Keys.I))
            {
                e.SuppressKeyPress = e.Handled = true;
                if (this.lvSessions.SelectedCount >= 1)
                {
                    if (this.lvSessions.SelectedCount == 2)
                    {
                        Session[] selectedSessions = this.GetSelectedSessions();
                        this.txtExec.SelectedText = string.Format("{0} {1} ", selectedSessions[0].fullUrl, selectedSessions[1].fullUrl);
                        this.txtExec.SelectionLength = 0;
                    }
                    else
                    {
                        Session firstSelectedSession = this.GetFirstSelectedSession();
                        this.txtExec.SelectedText = string.Format("{0} ", firstSelectedSession.fullUrl);
                        this.txtExec.SelectionLength = 0;
                    }
                }
            }
        }

        private bool txtExec_OnExecute(string sCommand)
        {
            doesSessionMatchCriteriaDelegate oDel = null;
            if (sCommand.StartsWith("?", StringComparison.Ordinal))
            {
                if (this.lvSessions.SelectedCount > 0)
                {
                    this.lvSessions.Focus();
                }
                return false;
            }
            if (sCommand.Equals("toolbar", StringComparison.OrdinalIgnoreCase))
            {
                FiddlerToolbar.Show();
                return false;
            }
            if (sCommand.Equals("tearoff", StringComparison.OrdinalIgnoreCase))
            {
                this.actTearoffInspectors();
                return false;
            }
            if (sCommand.Equals("about:cache", StringComparison.OrdinalIgnoreCase))
            {
                int num;
                int num2;
                FiddlerApplication.Log.LogString(FiddlerApplication.oProxy.ToString());
                FiddlerApplication.Log.LogString(DNSResolver.InspectCache());
                ThreadPool.GetMinThreads(out num, out num2);
                FiddlerApplication.Log.LogFormat("Threads (MinIdle)\nWorker: \t\t{0}\nCompletion Port:\t{1}\n", new object[] { num, num2 });
                ThreadPool.GetMaxThreads(out num, out num2);
                FiddlerApplication.Log.LogFormat("Threads (Max)\nWorker: \t\t{0}\nCompletion Port:\t{1}\n", new object[] { num, num2 });
                ThreadPool.GetAvailableThreads(out num, out num2);
                FiddlerApplication.Log.LogFormat("Threads (Available)\nWorker: \t\t{0}\nCompletion Port:\t{1}\n", new object[] { num, num2 });
                Utilities.activateTabByTitle("Log", FiddlerApplication.UI.tabsViews);
                return true;
            }
            if (sCommand.StartsWith("!dns ", StringComparison.OrdinalIgnoreCase) || sCommand.StartsWith("!nslookup ", StringComparison.OrdinalIgnoreCase))
            {
                string[] strArray = Utilities.Parameterize(sCommand);
                string sRemoteHost = (strArray.Length > 1) ? strArray[1] : string.Empty;
                try
                {
                    IPAddress[] addressArray = DNSResolver.GetIPAddressList(sRemoteHost, true, null);
                    StringBuilder builder = new StringBuilder();
                    builder.AppendFormat("\r\nFiddlerDNS> DNS Lookup for \"{0}\":\r\n", sRemoteHost);
                    foreach (IPAddress address in addressArray)
                    {
                        builder.AppendFormat("\t{0}\r\n", address.ToString());
                    }
                    FiddlerApplication.Log.LogString(builder.ToString());
                }
                catch
                {
                    FiddlerApplication.Log.LogFormat("FiddlerDNS> DNS Lookup for \"{0}\" failed.\r\n", new object[] { sRemoteHost });
                }
                Utilities.activateTabByTitle("Log", FiddlerApplication.UI.tabsViews);
                return true;
            }
            if (sCommand.Equals("about:config", StringComparison.OrdinalIgnoreCase))
            {
                AboutConfig.ShowAboutConfigPage();
                return true;
            }
            if (sCommand.Equals("about:connectoids", StringComparison.OrdinalIgnoreCase) || sCommand.Equals("about:network", StringComparison.OrdinalIgnoreCase))
            {
                if (FiddlerApplication.oProxy.oAllConnectoids != null)
                {
                    FiddlerApplication.Log.LogString(FiddlerApplication.oProxy.oAllConnectoids.ToString());
                }
                else
                {
                    FiddlerApplication.Log.LogString("No connectoids have been loaded.");
                }
                Utilities.activateTabByTitle("Log", FiddlerApplication.UI.tabsViews);
                return true;
            }
            if (sCommand.StartsWith("!listen", StringComparison.OrdinalIgnoreCase))
            {
                string[] strArray2 = Utilities.Parameterize(sCommand);
                if (strArray2.Length > 1)
                {
                    int num3 = int.Parse(strArray2[1]);
                    Proxy proxy = new Proxy(false);
                    if (strArray2.Length > 2)
                    {
                        if (!proxy.ActAsHTTPSEndpointForHostname(strArray2[2]))
                        {
                            MessageBox.Show(string.Format("Failed to create secure listener on port #{0} for {1}", num3, strArray2[2]), "Failure");
                        }
                        else
                        {
                            proxy.Start(num3, true);
                            MessageBox.Show(string.Format("Started new Secure Listener on port #{0} with certificate SubjectCN={1}", num3, strArray2[2]), "Success");
                            FiddlerApplication.Log.LogFormat("Started new Secure Listener on port #{0} with certificate SubjectCN={1}", new object[] { num3, strArray2[2] });
                        }
                    }
                    else
                    {
                        proxy.Start(num3, true);
                        MessageBox.Show(string.Format("Started new Listener on port #{0}", num3), "Success");
                        FiddlerApplication.Log.LogFormat("Started new Listener on port #{0}", new object[] { num3 });
                    }
                }
                return true;
            }
            if (sCommand.Equals("!throw", StringComparison.OrdinalIgnoreCase))
            {
                throw new Exception("User-requested");
            }
            if (sCommand.StartsWith("!gss", StringComparison.OrdinalIgnoreCase))
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                string[] strArray3 = Utilities.Parameterize(sCommand);
                if (strArray3.Length > 1)
                {
                    int iMax = int.Parse(strArray3[1]);
                    this.GetSelectedSessions(iMax);
                }
                else
                {
                    this.GetSelectedSessions();
                }
                MessageBox.Show(string.Format("Get Selected Sessions took {0}ms", stopwatch.ElapsedMilliseconds), "Stopwatch");
                return true;
            }
            if (sCommand.Equals("!gas", StringComparison.OrdinalIgnoreCase))
            {
                Stopwatch stopwatch2 = Stopwatch.StartNew();
                this.GetAllSessions();
                MessageBox.Show(string.Format("Get All Sessions took {0}ms", stopwatch2.ElapsedMilliseconds), "Stopwatch");
                return true;
            }
            if (sCommand.StartsWith("!lm", StringComparison.OrdinalIgnoreCase))
            {
                StringBuilder builder2 = new StringBuilder();
                string str2 = null;
                if (sCommand.StartsWith("!lm ", StringComparison.OrdinalIgnoreCase))
                {
                    str2 = sCommand.Substring(3).Trim();
                    builder2.AppendFormat("== LOADED ASSEMBLIES MATCHING '{0}'==\n", str2);
                }
                else
                {
                    builder2.Append(FiddlerApplication.GetDetailedInfo());
                    builder2.AppendLine("== LOADED ASSEMBLIES ==");
                }
                try
                {
                    foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        if ((str2 == null) || (new AssemblyName(assembly.FullName).Name.IndexOf(str2, StringComparison.OrdinalIgnoreCase) >= 0))
                        {
                            string location;
                            try
                            {
                                location = assembly.Location;
                            }
                            catch
                            {
                                location = "Unknown";
                            }
                            builder2.AppendFormat("{0}\n\t{1}\n\tRuntime: {2} \tGAC: {3}\n", new object[] { assembly.FullName, location, assembly.ImageRuntimeVersion, assembly.GlobalAssemblyCache });
                        }
                    }
                    FiddlerApplication.Log.LogString(builder2.ToString());
                    Utilities.activateTabByTitle("Log", FiddlerApplication.UI.tabsViews);
                }
                catch (Exception exception)
                {
                    FiddlerApplication.Log.LogFormat("Failed to gather information: {0}", new object[] { Utilities.DescribeException(exception) });
                }
                return true;
            }
            if (sCommand.Equals("!spew", StringComparison.OrdinalIgnoreCase))
            {
                if (!CONFIG.bDebugSpew)
                {
                    CONFIG.bDebugSpew = true;
                    FiddlerApplication.Log.LogString("DebugSpew is now enabled; use DbgView.exe to examine output.");
                    FiddlerApplication.DebugSpew(FiddlerApplication.GetDetailedInfo());
                    FiddlerApplication.DebugSpew("CONNECTIONS:\r\n");
                    FiddlerApplication.DebugSpew(string.Join("\r\n", RASInfo.GetConnectionNames()));
                    this.sbpInfo.Text = "DebugSpew is now enabled.";
                }
                else
                {
                    FiddlerApplication.Log.LogString("DebugSpew is now disabled.");
                    this.sbpInfo.Text = "DebugSpew is now disabled.";
                    CONFIG.bDebugSpew = false;
                }
                return true;
            }
            if (sCommand.Equals("!unload", StringComparison.OrdinalIgnoreCase))
            {
                FiddlerApplication.oExtensions.Dispose();
                return true;
            }
            if (sCommand.StartsWith("!verify"))
            {
                FiddlerApplication.oProxy.VerifyAttached();
                return true;
            }
            if (sCommand.StartsWith("!dupe ", StringComparison.OrdinalIgnoreCase))
            {
                string[] strArray4 = Utilities.Parameterize(sCommand);
                if (strArray4.Length > 1)
                {
                    this.lvSessions.BeginUpdate();
                    FiddlerApplication.SuppressReportUpdates = true;
                    Stopwatch stopwatch3 = Stopwatch.StartNew();
                    int num5 = int.Parse(strArray4[1]);
                    Session[] allSessions = this.GetAllSessions();
                    for (int i = 0; i < num5; i++)
                    {
                        foreach (Session session in allSessions)
                        {
                            session["ui-strikeout"] = "sure";
                            session.ViewItem = null;
                            this.finishSession(session);
                        }
                    }
                    this.lvSessions.EndUpdate();
                    FiddlerApplication.SuppressReportUpdates = false;
                    this.sbpInfo.Text = "Duplicated Session list in " + stopwatch3.ElapsedMilliseconds + "ms.";
                }
                return true;
            }
            if (sCommand.StartsWith("!fake ", StringComparison.OrdinalIgnoreCase))
            {
                this.lvSessions.BeginUpdate();
                FiddlerApplication.SuppressReportUpdates = true;
                string[] strArray5 = Utilities.Parameterize(sCommand);
                if (strArray5.Length > 1)
                {
                    int num7 = int.Parse(strArray5[1]);
                    for (int j = 0; j < num7; j++)
                    {
                        this.AddReportedSession(Encoding.ASCII.GetBytes(string.Format("GET /{0} HTTP/1.1\r\nHost: {0}.com\r\n\r\n", j.ToString())), Encoding.ASCII.GetBytes(string.Format("HTTP/1.1 {0} Fake\r\nContent-Length: 0\r\n\r\n", 200 + new Random().Next(400))), null, SessionFlags.ImportedFromOtherTool).ViewItem.ImageIndex = j % FiddlerApplication.UI.imglSessionIcons.Images.Count;
                    }
                }
                this.lvSessions.EndUpdate();
                FiddlerApplication.SuppressReportUpdates = false;
                return true;
            }
            if (sCommand.StartsWith("prefs", StringComparison.OrdinalIgnoreCase))
            {
                this._QuickExecHandlePrefs(Utilities.Parameterize(sCommand));
                return true;
            }
            if (sCommand.StartsWith("cols ", StringComparison.OrdinalIgnoreCase))
            {
                string[] strArray6 = Utilities.Parameterize(sCommand);
                if ((strArray6.Length > 2) && (strArray6[1] == "add"))
                {
                    if (strArray6.Length == 3)
                    {
                        if (this.lvSessions.AddBoundColumn(strArray6[2], 1, 80, strArray6[2]))
                        {
                            this.sbpInfo.Text = "Added column bound to " + strArray6[2];
                        }
                        else
                        {
                            this.sbpInfo.Text = "Failed to add column. Syntax: COLS ADD [TITLE] @COLLECTION.FLAGNAME";
                        }
                    }
                    else if (this.lvSessions.AddBoundColumn(strArray6[2], 1, 80, strArray6[3]))
                    {
                        this.sbpInfo.Text = string.Format("Added column \"{0}\" bound to {1}.", strArray6[2], strArray6[3]);
                    }
                    else
                    {
                        this.sbpInfo.Text = "Failed to add column. Syntax: COLS ADD [TITLE] @COLLECTION.FLAGNAME";
                    }
                }
                return true;
            }
            if (sCommand.StartsWith("select ", StringComparison.Ordinal))
            {
                string sCollection;
                string sHeaderOrFlag;
                string sMatch;
                string[] strArray7 = Utilities.Parameterize(sCommand);
                if (strArray7.Length < 2)
                {
                    return false;
                }
                if (strArray7.Length == 2)
                {
                    sCollection = "RESPONSE";
                    sHeaderOrFlag = "Content-Type";
                    sMatch = strArray7[1];
                }
                else
                {
                    sHeaderOrFlag = strArray7[1];
                    if (sHeaderOrFlag.StartsWith("@request.", StringComparison.OrdinalIgnoreCase))
                    {
                        sCollection = "REQUEST";
                        sHeaderOrFlag = sHeaderOrFlag.Substring(9);
                    }
                    else if (sHeaderOrFlag.StartsWith("@response.", StringComparison.OrdinalIgnoreCase))
                    {
                        sCollection = "RESPONSE";
                        sHeaderOrFlag = sHeaderOrFlag.Substring(10);
                    }
                    else if (sHeaderOrFlag.StartsWith("@col.", StringComparison.OrdinalIgnoreCase))
                    {
                        sCollection = "COLUMN";
                        sHeaderOrFlag = sHeaderOrFlag.Substring(5);
                    }
                    else
                    {
                        sCollection = "SESSION";
                    }
                    sMatch = strArray7[2];
                }
                if (sCollection == "COLUMN")
                {
                    this.lvSessions.SearchColumn(sHeaderOrFlag, sMatch);
                    return true;
                }
                if (sMatch == "*")
                {
                    sMatch = string.Empty;
                }
                if (sMatch == @"\*")
                {
                    sMatch = "*";
                }
                this.actSelectSessionsMatchingCriteria(delegate(Session oS)
                {
                    if (string.IsNullOrEmpty(sMatch))
                    {
                        switch (sCollection)
                        {
                            case "SESSION":
                                return oS.oFlags.ContainsKey(sHeaderOrFlag);

                            case "REQUEST":
                                return ((oS.oRequest != null) && (oS.oRequest.headers != null)) && oS.oRequest.headers.Exists(sHeaderOrFlag);
                        }
                        return ((oS.oResponse != null) && (oS.oResponse.headers != null)) && oS.oResponse.headers.Exists(sHeaderOrFlag);
                    }
                    string str = oS[sCollection, sHeaderOrFlag];
                    return (str != null) && (str.IndexOf(sMatch, StringComparison.OrdinalIgnoreCase) > -1);
                });
                this.sbpInfo.Text = string.Format("Selected sessions {0} where {1}'s {2}.Contains({3})", new object[] { this.lvSessions.SelectedCount, sCollection, sHeaderOrFlag, sMatch });
                if (this.lvSessions.SelectedCount > 0)
                {
                    this.lvSessions.Focus();
                }
                return true;
            }
            if (sCommand.StartsWith(">", StringComparison.Ordinal))
            {
                long num9;
                string s = sCommand.Substring(1).Replace("k", "000");
                if (long.TryParse(s, out num9))
                {
                    this.actSelectSessionsWithResponseSize(true, num9);
                    this.sbpInfo.Text = "Selected sessions returning >" + s + " bytes.";
                    if (this.lvSessions.SelectedCount > 0)
                    {
                        this.lvSessions.Focus();
                    }
                }
                else
                {
                    this.sbpInfo.Text = "Invalid integer for operator";
                }
                return true;
            }
            if (sCommand.StartsWith("<", StringComparison.Ordinal))
            {
                long num10;
                string str5 = sCommand.Substring(1).Replace("k", "000");
                if (long.TryParse(str5, out num10))
                {
                    this.actSelectSessionsWithResponseSize(false, num10);
                    this.sbpInfo.Text = "Selected sessions returning <" + str5 + " bytes.";
                    if (this.lvSessions.SelectedCount > 0)
                    {
                        this.lvSessions.Focus();
                    }
                }
                else
                {
                    this.sbpInfo.Text = "Invalid integer for operator";
                }
                return true;
            }
            if (sCommand.StartsWith("=", StringComparison.Ordinal))
            {
                uint num11;
                if (uint.TryParse(sCommand.Substring(1), out num11))
                {
                    this.actSelectSessionsWithResponseCode(num11);
                    this.sbpInfo.Text = "Selected sessions returning HTTP/" + num11.ToString() + ".";
                    if (this.lvSessions.SelectedCount > 0)
                    {
                        this.lvSessions.Focus();
                    }
                }
                else
                {
                    if (oDel == null)
                    {
                        oDel = delegate(Session oSess)
                        {
                            return oSess.HTTPMethodIs(sCommand.Substring(1));
                        };
                    }
                    this.actSelectSessionsMatchingCriteria(oDel);
                    this.sbpInfo.Text = "Selected sessions with HTTP Method: " + sCommand.Substring(1) + ".";
                    if (this.lvSessions.SelectedCount > 0)
                    {
                        this.lvSessions.Focus();
                    }
                }
                return true;
            }
            if (sCommand.StartsWith("@", StringComparison.Ordinal))
            {
                this.actSelectSessionsWithRequestHeaderValue("Host", sCommand.Substring(1));
                this.sbpInfo.Text = "Selected sessions for host: " + sCommand.Substring(1);
                if (this.lvSessions.SelectedCount > 0)
                {
                    this.lvSessions.Focus();
                }
                return true;
            }
            EventHandler<QuickExecEventArgs> onQuickExec = this.OnQuickExec;
            if (onQuickExec != null)
            {
                Delegate[] invocationList = onQuickExec.GetInvocationList();
                QuickExecEventArgs e = new QuickExecEventArgs(sCommand);
                foreach (EventHandler<QuickExecEventArgs> handler2 in invocationList)
                {
                    handler2(this, e);
                    if (e.bHandled)
                    {
                        return e.bAddToHistory;
                    }
                }
            }
            if (!FiddlerApplication.oExtensions.DoOnQuickExec(sCommand))
            {
                this.sbpInfo.Text = "FiddlerScript ExecAction handler failed.";
            }
            return true;
        }

        private void txtExec_TextChanged(object sender, EventArgs e)
        {
            SimpleEventHandler workFunction = null;
            if ((this.txtExec.TextLength > 1) && this.txtExec.Text.StartsWith("?", StringComparison.Ordinal))
            {
                if (workFunction == null)
                {
                    workFunction = delegate
                    {
                        FiddlerApplication.UIInvokeAsync(new MethodInvoker(this.doQuickSearch), null);
                    };
                }
                ScheduledTasks.ScheduleWork("InlineSearch", 15, workFunction);
            }
        }

        private void uihlpUpdateProcessFilterStatus()
        {
            if (!CONFIG.bIsViewOnly)
            {
                switch (CONFIG.iShowProcessFilter)
                {
                    case ProcessFilterCategories.All:
                        this.sbpProcessFilter.Text = "All Processes";
                        this.sbpProcessFilter.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[0x19]);
                        return;

                    case ProcessFilterCategories.Browsers:
                        this.sbpProcessFilter.Text = "Web Browsers";
                        this.sbpProcessFilter.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[0x1a]);
                        return;

                    case ProcessFilterCategories.NonBrowsers:
                        this.sbpProcessFilter.Text = "Non-Browser";
                        this.sbpProcessFilter.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[20]);
                        return;

                    case ProcessFilterCategories.HideAll:
                        this.sbpProcessFilter.Text = "Hide All";
                        this.sbpProcessFilter.Icon = Utilities.GetIconFromImage(this.imglSessionIcons.Images[14]);
                        return;
                }
            }
        }

        private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs ue)
        {
            Exception exceptionObject = (Exception)ue.ExceptionObject;
            if (CONFIG.bUseEventLogForExceptions)
            {
                _LogExceptionToEventLog(exceptionObject);
            }
            FiddlerApplication.ReportException(exceptionObject);
        }

        [CodeDescription("Rescan the Responses subfolder of the Captures folder and list available files in Fiddler tampering UIs.")]
        public void UpdateLoadFromCbx()
        {
            this.cbxLoadFrom.Items.Clear();
            this.cbxLoadFrom.Items.Add("Choose Response...");
            FiddlerApplication.oAutoResponder.ClearActionsFromUI();
            try
            {
                if (Directory.Exists(CONFIG.GetPath("TemplateResponses")))
                {
                    foreach (FileInfo info in new DirectoryInfo(CONFIG.GetPath("TemplateResponses")).GetFiles())
                    {
                        if (!info.Name.StartsWith("_", StringComparison.Ordinal))
                        {
                            this.cbxLoadFrom.Items.Add(info.Name);
                            FiddlerApplication.oAutoResponder.AddActionToUI(info.Name);
                        }
                    }
                }
                if (Directory.Exists(CONFIG.GetPath("Responses")))
                {
                    foreach (FileInfo info2 in new DirectoryInfo(CONFIG.GetPath("Responses")).GetFiles())
                    {
                        if (!info2.Name.StartsWith("_", StringComparison.Ordinal))
                        {
                            this.cbxLoadFrom.Items.Add(info2.Name);
                            FiddlerApplication.oAutoResponder.AddActionToUI(info2.Name);
                        }
                    }
                }
            }
            catch
            {
            }
            if (this.cbxLoadFrom.Items.Count > 0)
            {
                this.cbxLoadFrom.SelectedIndex = 0;
            }
            FiddlerApplication.oAutoResponder.AddActionToUI("*bpu");
            FiddlerApplication.oAutoResponder.AddActionToUI("*bpafter");
            FiddlerApplication.oAutoResponder.AddActionToUI("*drop");
            FiddlerApplication.oAutoResponder.AddActionToUI("*reset");
            FiddlerApplication.oAutoResponder.AddActionToUI("*delay:100");
            FiddlerApplication.oAutoResponder.AddActionToUI("*CORSPreflightAllow");
            FiddlerApplication.oAutoResponder.AddActionToUI("*flag:ui-backcolor=#FFD700");
            FiddlerApplication.oAutoResponder.AddActionToUI("*header:HeaderName=NewValue");
            FiddlerApplication.oAutoResponder.AddActionToUI("*redir:http://www.example.com");
            FiddlerApplication.oAutoResponder.AddActionToUI("http://www.example.com");
            FiddlerApplication.oAutoResponder.AddActionToUI("Find a file...");
            this.cbxLoadFrom.Items.Add("Find a file...");
        }

        public void updateSession(Session oSession)
        {
            ListViewItem viewItem = oSession.ViewItem;
            bool flag = oSession.ShouldBeHidden();
            if (!flag && (viewItem == null))
            {
                this._coreAddSession(oSession, false);
                viewItem = oSession.ViewItem;
            }
            if (flag && (viewItem != null))
            {
                oSession.ViewItem = null;
                this.lvSessions.RemoveOrDequeue(viewItem);
            }
            else
            {
                try
                {
                    viewItem.SubItems[2].Text = _obtainScheme(oSession);
                    viewItem.SubItems[10].Text = oSession.oFlags["ui-customcolumn"];
                    viewItem.SubItems[9].Text = oSession.oFlags["ui-comments"];
                    SessionListView.FillBoundColumns(oSession, viewItem);
                    switch (oSession.state)
                    {
                        case SessionStates.ReadingResponse:
                        case SessionStates.SendingResponse:
                            viewItem.ImageIndex = 2;
                            return;

                        case SessionStates.AutoTamperResponseBefore:
                        case SessionStates.AutoTamperResponseAfter:
                        case SessionStates.Done:
                            return;

                        case SessionStates.HandTamperResponse:
                            viewItem.ImageIndex = 3;
                            return;

                        case SessionStates.Aborted:
                            viewItem.ImageIndex = 14;
                            return;

                        case SessionStates.HandTamperRequest:
                            break;

                        default:
                            return;
                    }
                    viewItem.ImageIndex = 1;
                }
                catch (Exception)
                {
                }
            }
        }

        private void UpdateStatusBar(bool bMustRunNow)
        {
            SimpleEventHandler workFunction = null;
            if (!bMustRunNow && (FiddlerApplication.SuppressReportUpdates || (this.lvSessions.SelectedCount == 0)))
            {
                if (workFunction == null)
                {
                    workFunction = delegate
                    {
                        FiddlerApplication.UIInvokeAsync(new MethodInvoker(this._UpdateStatusBar), null);
                    };
                }
                ScheduledTasks.ScheduleWork("UpdateStatusBar", 100, workFunction);
            }
            else
            {
                this._UpdateStatusBar();
            }
        }

        private void UpdateUIFromPrefs()
        {
            SetMenuItemCheckedFromPref(this.miManipulateIgnoreImages, "fiddler.ui.rules.hideimages");
            SetMenuItemCheckedFromPref(this.miRulesIgnoreConnects, "fiddler.ui.rules.hideconnects");
            SetMenuItemCheckedFromPref(this.miRulesRemoveEncoding, "fiddler.ui.rules.removeencoding");
            SetMenuItemCheckedFromPref(this.miViewStayOnTop, "fiddler.ui.stayontop");
            base.TopMost = this.miViewStayOnTop.Checked;
            this.lvSessions.uiAsyncUpdateInterval = FiddlerApplication.Prefs.GetInt32Pref("fiddler.ui.sessionlist.updateinterval", 80);
        }

        private void WhenDetachedUnexpectedly(object sender, EventArgs e)
        {
            MethodInvoker oDel = null;
            if (base.InvokeRequired)
            {
                if (oDel == null)
                {
                    oDel = delegate
                    {
                        this.WhenDetachedUnexpectedly(null, null);
                    };
                }
                FiddlerApplication.UIInvokeAsync(oDel, null);
            }
            else
            {
                if (!FiddlerApplication.isClosing)
                {
                    base.SuspendLayout();
                    this.sbpCapture.Text = string.Empty;
                    this.sbpCapture.Style = StatusBarPanelStyle.OwnerDraw;
                    this.pnlTopNotice.Visible = true;
                    base.ResumeLayout();
                }
                FiddlerApplication.oProxy.Detach(true);
            }
        }

        protected override void WndProc(ref Message m)
        {
            if (((m.Msg == 5) && (1L == ((long)m.WParam))) && (CONFIG.QuietMode || CONFIG.bHideOnMinimize))
            {
                this.actMinimizeToTray();
            }
            else if (m.Msg == 0x4a)
            {
                this.HandleWMCopyData(m);
            }
            else if (m.Msg == 0x312)
            {
                if (m.LParam == ((IntPtr)((CONFIG.iHotkey << 0x10) + CONFIG.iHotkeyMod)))
                {
                    this.actRestoreWindow();
                }
            }
            else
            {
                base.WndProc(ref m);
            }
        }
    }
}

